|
|
@ -321,7 +321,7 @@ function afterWrite(status, handle, req, buffer) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function connectip(self, port, ip) { |
|
|
|
function connectip(self, port, ip, addressType) { |
|
|
|
self.remoteAddress = ip; |
|
|
|
self.remotePort = port; |
|
|
|
|
|
|
@ -330,7 +330,11 @@ function connectip(self, port, ip) { |
|
|
|
|
|
|
|
assert.ok(self._connecting); |
|
|
|
|
|
|
|
var connectReq = self._handle.connect(ip, port); |
|
|
|
if (addressType == 6) { |
|
|
|
var connectReq = self._handle.connect6(ip, port); |
|
|
|
} else { |
|
|
|
var connectReq = self._handle.connect(ip, port); |
|
|
|
} |
|
|
|
|
|
|
|
if (connectReq) { |
|
|
|
connectReq.oncomplete = afterConnect; |
|
|
@ -370,16 +374,12 @@ Socket.prototype.connect = function(port /* [host], [cb] */) { |
|
|
|
} else { |
|
|
|
timers.active(self); |
|
|
|
|
|
|
|
if (addressType != 4) { |
|
|
|
throw new Error("ipv6 addresses not yet supported by libuv"); |
|
|
|
} |
|
|
|
|
|
|
|
connectip(self, port, ip || '127.0.0.1'); |
|
|
|
connectip(self, port, ip || '127.0.0.1', ip ? addressType : 4); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
debug("connect: missing host"); |
|
|
|
connectip(self, port, '127.0.0.1'); |
|
|
|
connectip(self, port, '127.0.0.1', 4); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@ -462,12 +462,16 @@ exports.Server = Server; |
|
|
|
function toPort(x) { return (x = Number(x)) >= 0 ? x : false; } |
|
|
|
|
|
|
|
|
|
|
|
function listenip(self, ip, port) { |
|
|
|
function listenip(self, ip, port, addressType) { |
|
|
|
var r = 0; |
|
|
|
|
|
|
|
if (ip && port) { |
|
|
|
debug("bind to " + ip); |
|
|
|
r = self._handle.bind(ip, port); |
|
|
|
if (addressType == 6) { |
|
|
|
r = self._handle.bind6(ip, port); |
|
|
|
} else { |
|
|
|
r = self._handle.bind(ip, port); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (r) { |
|
|
@ -498,7 +502,7 @@ Server.prototype.listen = function() { |
|
|
|
} 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); |
|
|
|
listenip(self, '0.0.0.0', port, 4); |
|
|
|
|
|
|
|
} else { |
|
|
|
// The first argument is the port, the second an IP
|
|
|
@ -506,10 +510,7 @@ Server.prototype.listen = function() { |
|
|
|
if (err) { |
|
|
|
self.emit('error', err); |
|
|
|
} else { |
|
|
|
if (addressType != 4) { |
|
|
|
throw new Error("ipv6 addresses not yet supported by libuv"); |
|
|
|
} |
|
|
|
listenip(self, ip || '0.0.0.0', port); |
|
|
|
listenip(self, ip || '0.0.0.0', port, ip ? addressType : 4); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|