Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
net_uv: throw when people construct net.Socket(fd)
Browse files Browse the repository at this point in the history
Easier to catch compatibility errors.
  • Loading branch information
ry committed Aug 23, 2011
1 parent c4454d2 commit e3413f0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/net_uv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -245,7 +256,7 @@ Socket.prototype.destroy = function(exception) {

self._connectQueueCleanUp();

debug('destroy ' + this.fd);
debug('destroy');

this.readable = this.writable = false;

Expand All @@ -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;
Expand Down

0 comments on commit e3413f0

Please sign in to comment.