diff options
author | Fedor Indutny <fedor@indutny.com> | 2016-04-26 16:27:08 -0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2016-04-27 00:41:15 -0400 |
commit | cee4c25c9281d106f80b20ba7854bf9003f9357a (patch) | |
tree | 9beb756c9ae2613dcbb284c8af7d4f603bc16971 /test | |
parent | cc5d9767af69c453dbb27d2fa09d8f2e8913774d (diff) | |
download | android-node-v8-cee4c25c9281d106f80b20ba7854bf9003f9357a.tar.gz android-node-v8-cee4c25c9281d106f80b20ba7854bf9003f9357a.tar.bz2 android-node-v8-cee4c25c9281d106f80b20ba7854bf9003f9357a.zip |
net: introduce `Socket#connecting` property
There is no official way to figure out if the socket that you have on
hand is still connecting to the remote host. Introduce
`Socket#connecting`, which is essentially an unprefixed `_connecting`
property that we already had.
PR-URL: https://github.com/nodejs/node/pull/6404
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-net-connect-buffer.js | 2 | ||||
-rw-r--r-- | test/parallel/test-net-socket-connecting.js | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/test/parallel/test-net-connect-buffer.js b/test/parallel/test-net-connect-buffer.js index bd8efe1643..2c8acf331d 100644 --- a/test/parallel/test-net-connect-buffer.js +++ b/test/parallel/test-net-connect-buffer.js @@ -40,7 +40,7 @@ tcp.listen(common.PORT, function() { connectHappened = true; }); - console.log('_connecting = ' + socket._connecting); + console.log('connecting = ' + socket.connecting); assert.equal('opening', socket.readyState); diff --git a/test/parallel/test-net-socket-connecting.js b/test/parallel/test-net-socket-connecting.js new file mode 100644 index 0000000000..fdd84874af --- /dev/null +++ b/test/parallel/test-net-socket-connecting.js @@ -0,0 +1,21 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); + +const server = net.createServer((conn) => { + conn.end(); + server.close(); +}).listen(common.PORT, () => { + const client = net.connect(common.PORT, () => { + assert.strictEqual(client.connecting, false); + + // Legacy getter + assert.strictEqual(client._connecting, false); + client.end(); + }); + assert.strictEqual(client.connecting, true); + + // Legacy getter + assert.strictEqual(client._connecting, true); +}); |