title: Convert TCP client from c# to nodejs
body: <p>We are converting our TCP client written in c# code to nodejs.</p>
  
  <p>The TCP client in c# is written as:</p>
  
  <pre><code>    using (TcpClient tcpClient = new TcpClient())
      {
         tcpClient.Connect(HOST, port);
         NetworkStream stream = tcpClient.GetStream();
         StreamWriter streamWriter = new StreamWriter((Stream)stream);
         string str = "{ \"message\" : \"" + message + "\" }";
         streamWriter.Write(str);
         streamWriter.Flush();
         int num = 0;
         stream.WriteByte((byte)num);
         tcpClient.Close();
      }
  </code></pre>
  
  <hr>
  
  <p>The nodejs converted code is</p>
  
  <pre><code>     var client = new net.Socket();
       client.connect(PORT, HOST, function () {
          var command = { "message" : "message" };
          var message = JSON.stringify(command);
          client.write(message, function () {
             client.write('successfully sent the message');
             client.destroy();
          });
       });
  </code></pre>
  
  <p>This talk to a third party server. We are getting a correct response back from the server when using the c# while no response from nodejs</p>
  
  <p>Not sure what I am missing. Please help</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I finally figured it out, after using WireShark to inspect the packets. The C# code was appending a NULL (ascii: 00) to the message while the nodejs code wasn't after appending a NULL value, the third party server started responding to the request </p>