mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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>
This commit is contained in:
1 parent
fb6753c75c
commit
cbbe95e1e1
6 files changed
+55
-21
No files matched your search
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user