title: Transferring data through tcp sockets using nodejs
body: <p>I have a simple node application that sends data through tcp sockets. Essentially it’s two node applications a sender and a receiver, or a client and server. I can open two terminal shells on my localhost and see data transferring though tcp sockets, so I know it works. I want to send data from my localhost to my server with these applications but I can’t figure it out.. wether its the ip address routing or if I have to open tcp ports or disable firewalls, not sure. here's what the server and client apps look like when I can successfully send data on my localhost. I want to use this client app on my localhost and host the server app on my centos server and transfer data, is this possible? </p>
  
  <pre><code>  /*** TCP Client ***/
      /* Dependencies */
      var fs = require('fs');
      var hl7 = require('simple-hl7');
      /* Build TCP Server */
      var server = hl7.Server;
      var tcpClient = server.createTcpClient();
      /* Connection */
      tcpClient.connect('127.0.0.1', 6969);
      /* Get XML  */
      var msg = fs.readFileSync('./data/example.xml').toString();
      /* Send Message */
      setTimeout(function() {
          tcpClient.send(msg, function(ack) {
            console.log("ACK: ",ack.toString());
            console.log("\nsuccessful transfer");
            tcpClient.close();
          });
      }, 500);
  </code></pre>
  
  <p>the server can be found here. <a href="https://www.snip2code.com/Snippet/148120/A-simple-node-js-HL7-MLP-server--Saves-m" rel="nofollow noreferrer">click here</a>
  but heres the config code..</p>
  
  <pre><code>/*
      Config class
      vars:
      baseFolder: Where to save the messages
      port      : What port to listen on
      ip        : what ip to listen on
  */
  var Config = new function() {
      this.baseFolder = "data";
      this.port = 6969;
      this.ip = '127.0.0.1';
  }
  </code></pre>