mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 18:29:01 +00:00

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>
22 lines
537 B
JavaScript
22 lines
537 B
JavaScript
'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);
|
|
});
|