This makes it so that the stdin TTY-wrap stream gets ref'ed on
.resume() and unref'ed on .pause()
The semantics of the names "pause" and "resume" are a bit weird, but the
important thing is that this corrects an API change from 0.4 -> 0.6
which made it impossible to read from stdin multiple times, without
knowing when it might end up being closed. If no one has it open, this
lets the process die naturally.
LGTM'd by @ry
Don't allow `socket.destroy()` to run twice. The self-destruct sequence itself
is idempotent but it makes the 'close' and 'error' events fire more than once,
which may confuse listeners.
Fixes#2223.
Just a syntactic sugar for doing, for example:
var server = net.createServer(function (c) {
c.end('goodbye, cruel world!\r\n');
server.close().on('close', function () {
console.log('really, goodbye!');
});
}).listen(1337);
Fixes#1922.
This commit fixes two bugs in the handling of write requests when the connect()
call is still in progress.
1. The deferred write request's size was counted twice towards `.bytesWritten`.
2. The callback was not called. After connecting, `Socket.write()` was called
with three arguments (data, encoding, cb) but it ignored the third argument.
Coincidentally fixes test/simple/test-net-connect-buffer.js.
Only register once for listening when passing a callback to Server.listen(),
this prevents servers recycled using close() from invoking the callback when
Server.listen() is called later.
Sockets emitted by the 'connection' event are always connected, having
them emit the 'connect' event makes no sense. It only confused people,
as it's not clear if you have to listen to 'connect' or not.
That try..catch block was also very scary. It would silently swallow
exceptions in 'connect' listeners and destroy the socket. Makes no
sense.
Fixes#1047.
setImplementationMethods checks the type of a socket and defines different
behavior based on the type, so auto detect it if type not implicitly
specified.
Change to end() behavior in 33c339 was breaking it. end() should wait for
connection before dumping. Changed test-net-connect-timeout to use destroy()
instead.