title: Running php code inside a node.js socket server script
body: <p>I am running a normal TCP socket in javascript and uses node to execute. Before I send a response back to the client, I want to validate the data with some some php (mysql) code.
  How can I execute this code inside this javascript file?  All similar questions in STACKOVERFLOW asks about this code in HTML. (which is okay and I understand that part), But  this is a normal javascript file (executed in node).  The javascript code is below and I've marked the validation function call.</p>
  
  <pre><code>var net = require('net');
  
  var HOST = '192.168.0.6';
  var PORT = 8765;
  
  net.createServer(function(sock) {
  
      console.log('CONNECTED: ' + sock.remoteAddress +':'+ sock.remotePort);
  
      sock.on('data', function(data) {
          var output;
          var validScan;
  
          //This is the function call to a php file
          **validScan = validateScanTag(data);**
  
          console.log('DATA ' + sock.remoteAddress + ': ' + data);
          sock.write(validScan);
  
      });
  
      // Closing this instance of socket
      sock.on('close', function(data) {
          console.log('CLOSED: ' + sock.remoteAddress +' '+ sock.remotePort);
      });
  
  }).listen(PORT, HOST);
  
  console.log('Server listening on ' + HOST +':'+ PORT);
  </code></pre>
  
  <p>The validateScanTag executes a line lke :</p>
  
  <pre><code>$.post('getperiod.php', {hours:hrs, minutes:mins, seconds:secs, ddd:day},
  </code></pre>
  
  <p>But this dont work.  How can I call this 'geteriod.php' file from a javascript file?</p>