title: client server communication using node.js
body: <p>In my client machine i have the following code</p>
  
  <pre><code>client.js
      var fs      = require('fs');
      var http    = require('http');
      var qs      = require('querystring');
      var exec    = require('child_process').exec;
      var server = http.createServer(function(req, res) {
        switch(req.url) {
              case '/vm/list':
                  getVms(function(vmData) {
                      res.end(JSON.stringify(vmData));
                  });
                  break;
              case '/vm/start':
                  req.on('data', function(data) {
                      console.log(data.toString())
                      exec('CALL Hello.exe', function(err, data) {
                          console.log(err)
                          console.log(data.toString())
                          res.end('');
                      });
                  });
  
                  break;
          }
      });
  
      server.listen(9090);
      console.log("Server running on the port 9090");
  </code></pre>
  
  <p>in my server side machine am using following helper.js</p>
  
  <pre><code>var options = {
          host: '172.16.2.51',
          port: 9090,
          path: '/vm/start',
          method: 'POST'
      };
  
      var req = http.request(options, function(res) {
          res.on('data', function(d) {
              console.log(d.toString());
          });
      });
  
      req.on('error', function(e) {
          console.error(e);
      });
  
  
  req.end('');
  </code></pre>
  
  <p>while running node helper.js am getting <code>{ [Error: socket hang up] code: 'ECONNRESET' }</code></p>
  
  <p>it doesn’t print data.tostring() contained in the client side.</p>