mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
7bc3e16da1
PR-URL: https://github.com/nodejs/node/pull/55408 Refs: https://github.com/libuv/libuv/pull/4407 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
27 lines
741 B
JavaScript
27 lines
741 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const { checkSupportReusePort, options } = require('../common/net');
|
|
const net = require('net');
|
|
|
|
function test(host) {
|
|
const server1 = net.createServer();
|
|
const server2 = net.createServer();
|
|
server1.listen({ ...options, host }, common.mustCall(() => {
|
|
const port = server1.address().port;
|
|
server2.listen({ ...options, host, port }, common.mustCall(() => {
|
|
server1.close();
|
|
server2.close();
|
|
}));
|
|
}));
|
|
server1.on('error', common.mustNotCall());
|
|
server2.on('error', common.mustNotCall());
|
|
}
|
|
|
|
checkSupportReusePort()
|
|
.then(() => {
|
|
test('127.0.0.1');
|
|
common.hasIPv6 && test('::');
|
|
}, () => {
|
|
common.skip('The `reusePort` option is not supported');
|
|
});
|