|
|
@ -299,9 +299,8 @@ Socket.prototype.read = function(n) { |
|
|
|
|
|
|
|
Socket.prototype.listen = function() { |
|
|
|
debug('socket.listen'); |
|
|
|
var self = this; |
|
|
|
self.on('connection', arguments[0]); |
|
|
|
listen(self, null, null, null); |
|
|
|
this.on('connection', arguments[0]); |
|
|
|
listen(this, null, null, null); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -883,7 +882,6 @@ Socket.prototype.connect = function(options, cb) { |
|
|
|
this._sockname = null; |
|
|
|
} |
|
|
|
|
|
|
|
var self = this; |
|
|
|
var pipe = !!options.path; |
|
|
|
debug('pipe', pipe, options.path); |
|
|
|
|
|
|
@ -893,21 +891,20 @@ Socket.prototype.connect = function(options, cb) { |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof cb === 'function') { |
|
|
|
self.once('connect', cb); |
|
|
|
this.once('connect', cb); |
|
|
|
} |
|
|
|
|
|
|
|
this._unrefTimer(); |
|
|
|
|
|
|
|
self._connecting = true; |
|
|
|
self.writable = true; |
|
|
|
this._connecting = true; |
|
|
|
this.writable = true; |
|
|
|
|
|
|
|
if (pipe) { |
|
|
|
connect(self, options.path); |
|
|
|
|
|
|
|
connect(this, options.path); |
|
|
|
} else { |
|
|
|
lookupAndConnect(self, options); |
|
|
|
lookupAndConnect(this, options); |
|
|
|
} |
|
|
|
return self; |
|
|
|
return this; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -1198,11 +1195,10 @@ exports._createServerHandle = createServerHandle; |
|
|
|
|
|
|
|
Server.prototype._listen2 = function(address, port, addressType, backlog, fd) { |
|
|
|
debug('listen2', address, port, addressType, backlog, fd); |
|
|
|
var self = this; |
|
|
|
|
|
|
|
// If there is not yet a handle, we need to create one and bind.
|
|
|
|
// In the case of a server sent via IPC, we don't need to do this.
|
|
|
|
if (self._handle) { |
|
|
|
if (this._handle) { |
|
|
|
debug('_listen2: have a handle already'); |
|
|
|
} else { |
|
|
|
debug('_listen2: create a handle'); |
|
|
@ -1227,22 +1223,22 @@ Server.prototype._listen2 = function(address, port, addressType, backlog, fd) { |
|
|
|
|
|
|
|
if (typeof rval === 'number') { |
|
|
|
var error = exceptionWithHostPort(rval, 'listen', address, port); |
|
|
|
process.nextTick(emitErrorNT, self, error); |
|
|
|
process.nextTick(emitErrorNT, this, error); |
|
|
|
return; |
|
|
|
} |
|
|
|
self._handle = rval; |
|
|
|
this._handle = rval; |
|
|
|
} |
|
|
|
|
|
|
|
self._handle.onconnection = onconnection; |
|
|
|
self._handle.owner = self; |
|
|
|
this._handle.onconnection = onconnection; |
|
|
|
this._handle.owner = this; |
|
|
|
|
|
|
|
var err = _listen(self._handle, backlog); |
|
|
|
var err = _listen(this._handle, backlog); |
|
|
|
|
|
|
|
if (err) { |
|
|
|
var ex = exceptionWithHostPort(err, 'listen', address, port); |
|
|
|
self._handle.close(); |
|
|
|
self._handle = null; |
|
|
|
process.nextTick(emitErrorNT, self, ex); |
|
|
|
this._handle.close(); |
|
|
|
this._handle = null; |
|
|
|
process.nextTick(emitErrorNT, this, ex); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -1253,7 +1249,7 @@ Server.prototype._listen2 = function(address, port, addressType, backlog, fd) { |
|
|
|
if (this._unref) |
|
|
|
this.unref(); |
|
|
|
|
|
|
|
process.nextTick(emitListeningNT, self); |
|
|
|
process.nextTick(emitListeningNT, this); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -1522,15 +1518,14 @@ Server.prototype.close = function(cb) { |
|
|
|
|
|
|
|
Server.prototype._emitCloseIfDrained = function() { |
|
|
|
debug('SERVER _emitCloseIfDrained'); |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (self._handle || self._connections) { |
|
|
|
if (this._handle || this._connections) { |
|
|
|
debug('SERVER handle? %j connections? %d', |
|
|
|
!!self._handle, self._connections); |
|
|
|
!!this._handle, this._connections); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
process.nextTick(emitCloseNT, self); |
|
|
|
process.nextTick(emitCloseNT, this); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|