summaryrefslogtreecommitdiff
path: root/lib/net.js
AgeCommit message (Collapse)Author
2013-05-27Merge remote-tracking branch 'ry/v0.10'isaacs
Conflicts: AUTHORS ChangeLog configure deps/uv/ChangeLog deps/uv/src/unix/darwin.c deps/uv/src/unix/stream.c deps/uv/src/version.c deps/v8/src/isolate.cc deps/v8/src/version.cc lib/http.js src/node_version.h
2013-05-21net: use timers._unrefActive for internal timeoutsTimothy J Fontaine
2013-05-21util: Add debuglog, deprecate console lookalikesisaacs
2013-05-17Merge remote-tracking branch 'ry/v0.10' into masterisaacs
Conflicts: AUTHORS ChangeLog deps/uv/ChangeLog deps/uv/config-unix.mk deps/uv/src/unix/stream.c deps/uv/src/version.c deps/uv/uv.gyp src/node.cc src/node_buffer.cc src/node_crypto.cc src/node_version.h src/stream_wrap.cc src/stream_wrap.h
2013-05-15net: emit dns 'lookup' event before connectBen Noordhuis
net.connect() and net.createConnection() now emit a 'lookup' event after resolving the hostname but before connecting. Fixes #5418.
2013-04-27net: implement ._writev for .cork/uncork() supportFedor Indutny
Add Writev method to StreamWrap class for writing mixed array of strings and buffers. Expose this method for TCP class.
2013-04-11lintisaacs
2013-04-10net: fix socket.bytesWritten Buffers supportFedor Indutny
Buffer.byteLength() works only for string inputs. Thus, when connection has pending Buffer to write, it should just use it's length instead of throwing exception.
2013-04-08net: account encoding in .byteLengthFedor Indutny
2013-04-08net: fix buffer iteration in bytesWrittenFedor Indutny
2013-03-14net: improve arbitrary tcp socket supportBen Noordhuis
Consider this example: // fd 3 is a bound tcp socket var s = net.createServer(cb); s.listen({ fd: 3 }); console.log(s.address()); // prints null This commit makes net.Server#address() print the actual address. Ditto for non-listen sockets; properties like net.Socket#localAddress and net.Socket#remoteAddress now return the correct value. Fixes #5009.
2013-03-14deps: upgrade libuv to 7b66ea1Ben Noordhuis
2013-03-13net: handle 'finish' event only after 'connect'Fedor Indutny
2013-03-06net: use close callback, not process.nextTickBen Noordhuis
Don't emit the 'close' event with process.nextTick. Closing a handle is an operation that usually *but not always* completes on the next tick of the event loop, hence using process.nextTick is not reliable. Use a proper handle close callback and emit the 'close' event from inside the callback. Update tests that depend on the intricacies of the old model. Fixes #3459.
2013-03-05stream: _write takes an encoding argumentisaacs
This vastly reduces the overhead of decodeStrings:false streams, such as net and http.
2013-03-05stream: Split Writable logic into small functionsisaacs
1. Get rid of unnecessary 'finishing' flag 2. Dont check both ending and ended. Extraneous. Also: Remove extraneous 'finishing' flag, and don't check both 'ending' and 'ended', since checking just 'ending' is sufficient.
2013-03-05Merge remote-tracking branch 'origin/v0.8'Ben Noordhuis
2013-03-05cluster: propagate bind errorsBen Noordhuis
This commit fixes a bug where the cluster module fails to propagate EADDRINUSE errors. When a worker starts a (net, http) server, it requests the listen socket from its master who then creates and binds the socket. Now, OS X and Windows don't always signal EADDRINUSE from bind() but instead defer the error until a later syscall. libuv mimics this behaviour to provide consistent behaviour across platforms but that means the worker could end up with a socket that is not actually bound to the requested addresss. That's why the worker now checks if the socket is bound, raising EADDRINUSE if that's not the case. Fixes #2721.
2013-03-02net: s/closed/ended/ in write-after-fin messageisaacs
2013-03-02net: Provide better error when writing after FINisaacs
The stock writable stream "write after end" message is overly vague, if you have clearly not called end() yourself yet. When we receive a FIN from the other side, and call destroySoon() as a result, then generate an EPIPE error (which is what would happen if you did actually write to the socket), with a message explaining what actually happened.
2013-02-28stream: There is no _read cb, there is only pushisaacs
This makes it so that `stream.push(chunk)` is the only way to signal the end of reading, removing the confusing disparity between the callback-style _read method, and the fact that most real-world streams do not have a 1:1 corollation between the "please give me data" event, and the actual arrival of a chunk of data. It is still possible, of course, to implement a `CallbackReadable` on top of this. Simply provide a method like this as the callback: function readCallback(er, chunk) { if (er) stream.emit('error', er); else stream.push(chunk); } However, *only* fs streams actually would behave in this way, so it makes not a lot of sense to make TCP, TLS, HTTP, and all the rest have to bend into this uncomfortable paradigm.
2013-03-01net: omit superfluous 'connect' eventBen Noordhuis
Don't emit a 'connect' event on sockets that are handed off to net.Server 'connection' event listeners. 1. It's superfluous because the connection has already been established at that point. 2. The implementation is arguably wrong because the event is emitted on the same tick of the event loop while the rule of thumb is to always emit it on the next one. This has been tried before in commit f0a440d but was reverted again in ede1acc because the change was incomplete (at least one test hadn't been updated). Fixes #1047 (again).
2013-02-28lib, src: remove errno globalBen Noordhuis
Remove the errno global. It's a property on the process object now. Fixes #3095.
2013-02-12net: Respect the 'readable' flag on socketsisaacs
Previously, we were only destroying sockets on end if their readable side had already been ended. This causes a problem for non-readable streams, since we don't expect to ever see an 'end' event from those. Treat the lack of a 'readable' flag the same as if it was an ended readable stream. Fix #4751
2013-02-11net: don't suppress ECONNRESETBen Noordhuis
Let ECONNRESET network errors bubble up so clients can detect them. Commit c4454d2e suppressed and turned them into regular end-of-stream events to fix the then-failing simple/test-regress-GH-1531 test. See also issue #1571 for (scant) details. It turns out that special handling is no longer necessary. Remove the special casing and let the error bubble up naturally. pummel/test-https-ci-reneg-attack and pummel/test-tls-ci-reneg-attack are updated because they expected an EPIPE error code that is now an ECONNRESET. Suppression of the ECONNRESET prevented the test from detecting that the connection has been severed whereupon the next write would fail with an EPIPE. Fixes #1776.
2013-01-28Revert "net: Avoid tickDepth warnings on small writes"isaacs
This commit breaks simple/test-stream2-stderr-sync. Need to figure out a better way, or just accept that `(function W(){stream.write(b,W)})()` is going to be noisy. People should really be using the `'drain'` event for this use-case anyway. This reverts commit 02f7d1bfd8b5b75620352774967dce63b0934037.
2013-01-28net: Avoid tickDepth warnings on small writesisaacs
Always defer the _write callback. The optimization here was only relevant in some oddball edge cases that we don't actually care about. Our benchmarks confirm that just always deferring the Socket._write cb is perfectly fine to do, and in some cases, even slightly more performant.
2013-01-28child_process: move binding init in constructorFedor Indutny
Doing this in net.Socket constructor has much more overhead, and error is actually may happen before the construction of socket object.
2013-01-28net: Initialize _connection, _handle in Socket ctorisaacs
The better to reduce the hidden classes
2013-01-28net: initialize TCPWrap when receiving socketFedor Indutny
TCPWrap::Initialize() and PipeWrap::Initialize() should be called before any data will be read from received socket. But, because of lazy initialization of these bindings, Initialize() method isn't called. Init bindings manually upon socket receiving. See #4669
2013-01-18child_process: do not keep list of sent socketsFedor Indutny
Keeping list of all sockets that were sent to child process causes memory leak and thus unacceptable (see #4587). However `server.close()` should still work properly. This commit introduces two options: * child.send(socket, { track: true }) - will send socket and track its status. You should use it when you want to receive `close` event on sent sockets. * child.send(socket) - will send socket without tracking it status. This performs much better, because of smaller number of RTT between master and child. With both of these options `server.close()` will wait for all sent sockets to get closed.
2013-01-18Revert "child_process: do not keep list of sent sockets"Fedor Indutny
This reverts commit db5ee0b3decace9b5d80ee535ce53183aff02909.
2013-01-17child_process: do not keep list of sent socketsFedor Indutny
Keeping list of all sockets that were sent to child process causes memory leak and thus unacceptable (see #4587). However `server.close()` should still work properly. This commit introduces two options: * child.send(socket, { track: true }) - will send socket and track its status. You should use it when you want `server.connections` to be a reliable number, and receive `close` event on sent sockets. * child.send(socket) - will send socket without tracking it status. This performs much better, because of smaller number of RTT between master and child. With both of these options `server.close()` will wait for all sent sockets to get closed.
2013-01-17stdio: Set readable/writable flags properlyisaacs
Set the readable/writable flags properly in net streams that have a handle passed in (such as TTY streams). Fix #4606
2013-01-10net: Use readable.push() instead of private methodsisaacs
2013-01-08net: fix bufferSize include writableStream lengthShigeki Ohtsu
socket.bufferSize missed to include the length of internal buffers in writableStream.
2013-01-07child_process: Pull through untouched stdio streamsisaacs
Otherwise child procs will never emit a 'close' event if you don't ever consume their streams, because they will never hit the EOF.
2013-01-05net: add localAddress and localPort to SocketJames Hight
2012-12-29net: Don't go through Stream API when ondata is usedisaacs
This speeds up http_simple by around 6%.
2012-12-29net: Move createWriteReq to separate functionisaacs
2012-12-27net: socket.readyState correctionsbentaber
socket.readyState, .readable, and .writable behavior changed as a result of the new streaming interfaces. Updated to be backwards compatible with current API and adds regression test. closes #4461
2012-12-25net: allow socket end before connectBen Taber
Fix a bug where calling .end() on a socket without calling .connect() first throws a TypeError: TypeError: Cannot read property 'shutdown' of undefined at Socket.onSocketFinish (net.js:194:20) at Socket.EventEmitter.emit (events.js:91:17) at Socket.Writable.end (_stream_writable.js:281:10) at Socket.end (net.js:352:31) Fixes #4463.
2012-12-21stdio: Do not read from stdout/errisaacs
This fixes windows stdio pipes in streams2 land.
2012-12-19net: Properly read buffer in Socket.bytesWrittenisaacs
2012-12-17net: Handle sync writable streams synchronouslyisaacs
This fixes the case where stderr doesn't flush before the process exits.
2012-12-14net: Refactor to use streams2isaacs
This is a combination of 6 commits. * XXX net fixup lcase stream * net: Refactor to use streams2 Use 'socket.resume()' in many tests to trigger old-mode behavior. * net: Call destroy() if shutdown() is not provided This is important for TTY wrap streams * net: Call .end() in socket.destroySoon if necessary This makes the http 1.0 keepAlive test pass, also. * net wtf-ish stuff kinda busted * net fixup
2012-12-13Merge remote-tracking branch 'ry/v0.8' into masterisaacs
Conflicts: AUTHORS ChangeLog deps/uv/test/test-spawn.c deps/uv/uv.gyp src/cares_wrap.cc src/node.cc src/node_version.h test/simple/test-buffer.js tools/gyp/pylib/gyp/common.py tools/install.py
2012-11-28net: More accurate IP address validation and IPv6 dotted notation.Joshua Erickson
* Added isIP method to make use of inet_pton to cares_wrap.cc * Modified net.isIP() to make use of new C++ isIP method. * Added new tests to test-net-isip.js. This is a back-port of commit fb6377e from the master branch.
2012-11-24net: fix net.connect() resource leakBen Noordhuis
The 'connect' event listener was attached with .on(), which blocked it from getting garbage collected. Use .once() instead. Fixes #4308.
2012-11-21windows: add tracing with performance countersScott Blomquist
Patch by Henry Rawas and Scott Blomquist.