title: How to get the port number in node.js when a request is processed?
body: <p>If I have two node.js servers running, how can I tell which server called the processRequest function?</p>
  
  <pre><code>var http = require('http');
  var https = require('https');
  function processRequest(req, res) {
      res.writeHead(200);
      res.end("hello world, I'm on port: " + ???.port + "\n");
  }
  var server1 = http.createServer(processRequest).listen(80);
  var server2 = https.createServer(processRequest).listen(443);
  </code></pre>
  
  <p>Originally I wanted the port number, but couldn't find the object/variable to give it to me.  Based on the below answer it makes more sense to determine encrypted vs non-encrypted since the point is to know which of the http servers the request came in on.</p>