Browse Source

net_uv: Fix server.listen argument parsing

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
be1b55289f
  1. 16
      lib/net_uv.js

16
lib/net_uv.js

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

Loading…
Cancel
Save