0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

net_uv: Fix server.listen argument parsing

This commit is contained in:
Ryan Dahl 2011-06-29 18:04:55 +02:00
parent 33af2720f2
commit be1b55289f

View File

@ -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);