2017-03-09 03:36:15 +00:00
|
|
|
'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();
|
|
|
|
}));
|
|
|
|
|
2022-01-07 16:24:40 +00:00
|
|
|
const address = server.address();
|
2022-05-10 09:10:03 +00:00
|
|
|
if (!common.hasIPv6 && address.family === 'IPv6') {
|
2022-01-07 16:24:40 +00:00
|
|
|
// Necessary to pass CI running inside containers.
|
|
|
|
client.connect(address.port);
|
|
|
|
} else {
|
|
|
|
client.connect(address);
|
|
|
|
}
|
2017-03-09 03:36:15 +00:00
|
|
|
}));
|