title: Nodejs socket connection error
body: <p>I have written this code that sends packet to a socket and reads from it. But when i run it , i get the data from socket but the code throws an error by saying read ECONNRESET. Am I doing anything wrong?</p>
  
  <pre><code>var client = net.connect({port:remotePort, host:remoteIpAddress},function(){    
      client.write(packet);
  });
  client.on('data',function(chunkData){       
      console.log(chunkData);
      client.end();
  }); 
  
  client.on('end',function(){
      console.log("Reading end");
  });
  
  client.on('error', function(err){
      console.log("Error: "+err.message);
  })
  </code></pre>