diff options
author | Evan Lucas <evanlucas@me.com> | 2015-02-18 12:02:01 -0600 |
---|---|---|
committer | Evan Lucas <evanlucas@me.com> | 2015-05-19 13:21:44 -0500 |
commit | 85d99830096a48b7d50cc3b0e5c3fba4172c2d02 (patch) | |
tree | 758ca8abc3dc4107dcc4492e7b54f5c52b31c089 /test/parallel/test-net-persistent-keepalive.js | |
parent | 3c44100558b4e9e48e0e711e38acc91e0f870a9f (diff) | |
download | android-node-v8-85d99830096a48b7d50cc3b0e5c3fba4172c2d02.tar.gz android-node-v8-85d99830096a48b7d50cc3b0e5c3fba4172c2d02.tar.bz2 android-node-v8-85d99830096a48b7d50cc3b0e5c3fba4172c2d02.zip |
net: persist net.Socket options before connect
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.
This change makes the following function calls more user-friendly:
- setKeepAlive()
- setNoDelay()
- ref()
- unref()
Related: https://github.com/joyent/node/issues/7077 and
https://github.com/joyent/node/issues/8572
Fixes: https://github.com/joyent/node/issues/7077
Fixes: https://github.com/joyent/node/issues/8572
PR-URL: https://github.com/nodejs/io.js/pull/1518
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'test/parallel/test-net-persistent-keepalive.js')
-rw-r--r-- | test/parallel/test-net-persistent-keepalive.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/parallel/test-net-persistent-keepalive.js b/test/parallel/test-net-persistent-keepalive.js new file mode 100644 index 0000000000..adf7d7a4fa --- /dev/null +++ b/test/parallel/test-net-persistent-keepalive.js @@ -0,0 +1,33 @@ +'use strict'; +var common = require('../common'); +var assert = require('assert'); +var net = require('net'); + +var serverConnection; +var echoServer = net.createServer(function(connection) { + serverConnection = connection; + connection.setTimeout(0); + assert.equal(typeof connection.setKeepAlive, 'function'); + connection.on('end', function() { + connection.end(); + }); +}); +echoServer.listen(common.PORT); + +echoServer.on('listening', function() { + var clientConnection = new net.Socket(); + // send a keepalive packet after 1000 ms + // and make sure it persists + clientConnection.setKeepAlive(true, 400); + clientConnection.connect(common.PORT); + clientConnection.setTimeout(0); + + setTimeout(function() { + // make sure both connections are still open + assert.equal(serverConnection.readyState, 'open'); + assert.equal(clientConnection.readyState, 'open'); + serverConnection.end(); + clientConnection.end(); + echoServer.close(); + }, 600); +}); |