|
|
@ -399,7 +399,13 @@ function toPort(x) { return (x = Number(x)) >= 0 ? x : false; } |
|
|
|
|
|
|
|
|
|
|
|
function listenip(self, ip, port) { |
|
|
|
var r = self._handle.bind(ip, port); |
|
|
|
var r = 0; |
|
|
|
|
|
|
|
if (ip && port) { |
|
|
|
debug("bind to " + ip); |
|
|
|
r = self._handle.bind(ip, port); |
|
|
|
} |
|
|
|
|
|
|
|
if (r) { |
|
|
|
self.emit('error', errnoException(errno, 'listen')); |
|
|
|
} else { |
|
|
@ -423,12 +429,10 @@ Server.prototype.listen = function() { |
|
|
|
if (arguments.length == 0 || typeof arguments[0] == 'function') { |
|
|
|
// Don't bind(). OS will assign a port with INADDR_ANY.
|
|
|
|
// The port can be found with server.address()
|
|
|
|
this._handle.listen(self._backlog || 128); |
|
|
|
process.nextTick(function() { |
|
|
|
self.emit('listening'); |
|
|
|
}); |
|
|
|
listenip(self, null, null); |
|
|
|
|
|
|
|
} else if (typeof arguments[1] == 'undefined') { |
|
|
|
} else if (typeof arguments[1] == 'undefined' || |
|
|
|
typeof arguments[1] == 'function') { |
|
|
|
// The first argument is the port, no IP given.
|
|
|
|
listenip(self, '0.0.0.0', port); |
|
|
|
|
|
|
|