title: TCP socket.write function in node.js' "net" package not writing to socket
body: <p>I am having some trouble writing 2 messages to a TCP socket using node.js' net package.</p>
  
  <p>The code:</p>
  
  <pre><code>var net = require('net');
  
  
  var HOST = '20.100.2.62';
  var PORT = '5555';
  
  var socket = new net.Socket();
  
  socket.connect (PORT, HOST, function() {
  console.log('CONNECTED TO: ' + HOST + ':' + PORT);
  // Write a message to the socket as soon as the client is connected, the server will   receive it as message from the client 
    socket.write('@!&gt;');       
    socket.write('RIG,test,test,3.1');
  
  });
  
  
  
  // Add a 'data' event handler for the client socket
  // data is what the server sent to this socket
  socket.on('data', function(data) {
    console.log('DATA: ' + data);
    // Close the client socket completely
    //    client.destroy();
  });
  
  socket.on('error', function(exception){
    console.log('Exception:');
    console.log(exception);
  });
  
  
  socket.on('drain', function() {
    console.log("drain!");
  });
  
  socket.on('timeout', function() {
    console.log("timeout!");
  });
  
  // Add a 'close' event handler for the client socket
  socket.on('close', function() {
     console.log('Connection closed');
  });
  </code></pre>
  
  <p>I've also tried the supposedly more correct net.createConnection(arguments...) function from the net package with no luck.</p>
  
  <p>I can see on my server side that the connection to the socket happens just as expected but there is no data received by the server which is why I'm suspecting that something is wrong with the way I'm using the socket.write function. Perhaps the first strings characters are causing confusion?</p>
  
  <p>Any help would be greatly appreciated. </p>
  
  <p>Many thanks.</p>