summaryrefslogtreecommitdiff
path: root/lib/net_uv.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-09-12 14:59:51 -0700
committerRyan Dahl <ry@tinyclouds.org>2011-09-12 15:09:44 -0700
commitcaaa59c559f4ed8b26ab1438f4104f4e93adb098 (patch)
tree75fc658a6b126d597985dc0ac05e6333a4b8f391 /lib/net_uv.js
parent51f2e8439e4e26f7f3b58193112916c711085c91 (diff)
downloadnode-caaa59c559f4ed8b26ab1438f4104f4e93adb098.tar.gz
Wrap uv_pipe_open, implement net.Stream(fd);
Fixes simple/test-child-process-ipc on unix.
Diffstat (limited to 'lib/net_uv.js')
-rw-r--r--lib/net_uv.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/net_uv.js b/lib/net_uv.js
index 97470f825..dddc03fcb 100644
--- a/lib/net_uv.js
+++ b/lib/net_uv.js
@@ -78,21 +78,24 @@ 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();
+ // Legacy interface.
// 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")
- }
+ var fd = options;
- // private
- this._handle = options && options.handle;
- initSocketHandle(this);
-
- this.allowHalfOpen = options && options.allowHalfOpen;
+ // Uncomment the following lines after libuv backend is stable and API
+ // compatibile with legaacy.
+ // console.error('Deprecated interface net.Socket(fd).');
+ // console.trace();
+ this._handle = createPipe();
+ this._handle.open(fd);
+ initSocketHandle(this);
+ } else {
+ // private
+ this._handle = options && options.handle;
+ initSocketHandle(this);
+ this.allowHalfOpen = options && options.allowHalfOpen;
+ }
}
util.inherits(Socket, stream.Stream);