net_uv: throw when people construct net.Socket(fd)

Easier to catch compatibility errors.
pull/22966/head
Ryan Dahl 2011-08-23 02:31:20 -07:00
parent c4454d2efc
commit e3413f08fd
1 changed files with 13 additions and 2 deletions

View File

@ -84,6 +84,17 @@ function Socket(options) {
stream.Stream.call(this);
if (typeof options == 'number') {
// Legacy interface. Uncomment the following lines after
// libuv backend is stable and API compatibile with legaacy.
// console.error('Deprecated interface net.Socket(fd).');
// console.trace();
// Must support legacy interface. NPM depends on it.
// https://github.com/isaacs/npm/blob/c7824f412f0cb59d6f55cf0bc220253c39e6029f/lib/utils/output.js#L110
// TODO Before we can do this we need a way to open a uv_stream_t by fd.
throw new Error("Not yet implemented")
}
// private
this._handle = options && options.handle;
initSocketHandle(this);
@ -245,7 +256,7 @@ Socket.prototype.destroy = function(exception) {
self._connectQueueCleanUp();
debug('destroy ' + this.fd);
debug('destroy');
this.readable = this.writable = false;
@ -256,7 +267,7 @@ Socket.prototype.destroy = function(exception) {
this.server._emitCloseIfDrained();
}
debug('close ' + this.fd);
debug('close');
if (this._handle) {
this._handle.close();
this._handle = null;