mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
70b516e4db
Refs: https://github.com/nodejs/node/issues/43014 PR-URL: https://github.com/nodejs/node/pull/43054 Fixes: https://github.com/nodejs/node/issues/43014 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
27 lines
658 B
JavaScript
27 lines
658 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
// This test ensures that socket.connect can be called without callback
|
|
// which is optional.
|
|
|
|
const net = require('net');
|
|
|
|
const server = net.createServer(common.mustCall(function(conn) {
|
|
conn.end();
|
|
server.close();
|
|
})).listen(0, common.mustCall(function() {
|
|
const client = new net.Socket();
|
|
|
|
client.on('connect', common.mustCall(function() {
|
|
client.end();
|
|
}));
|
|
|
|
const address = server.address();
|
|
if (!common.hasIPv6 && address.family === 'IPv6') {
|
|
// Necessary to pass CI running inside containers.
|
|
client.connect(address.port);
|
|
} else {
|
|
client.connect(address);
|
|
}
|
|
}));
|