title: node httpServer EADDRINUSE and next port
body: <p>I try to increment a port number based on 8000 if the port is busy with <code>EADDRINUSE</code>, and I thought it's as easy as the below:</p>
  
  <pre><code>            var tryToOpenServer = function(port)
              {
                console.log('trying to Open: ' + port);
  
                HTTPserver
                  .listen(port, function()
                  {
                    console.log('HTTP listening:' + port);
                  })
                  .on('error', function(err)
                  {
                    if (err.code === 'EADDRINUSE')
                    {
                      // port is currently in use
                      console.log('server Open error:' + port);
  
                      tryToOpenServer(port + 1);
                    }
                  });
  
              };
  
              tryToOpenServer(8000);
  </code></pre>
  
  <p>If the port:8000 is busy and got <code>err.code</code> === 'EADDRINUSE', the port is incremented and the code tries the port. The problem is that</p>
  
  <pre><code>                .listen(port, function()
                  {
                    console.log('HTTP listening:' + port);
                  })
  </code></pre>
  
  <p>The above code somehow successfully runs on port:8000 even it throws an 'EADDRINUSE', so I've got 2 notifications: HTTP 8000 and 8001.</p>
  
  <p>What do I miss? Please let me know thanks.</p>