0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-net-reuseport.js
Luigi Pinca 84fe809535
test: remove unneeded listeners
Unhandled `'error'` events will make the process exit with an unclean
exit code anyway.

PR-URL: https://github.com/nodejs/node/pull/55486
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
2024-10-29 21:52:09 +00:00

25 lines
651 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();
}));
}));
}
checkSupportReusePort()
.then(() => {
test('127.0.0.1');
common.hasIPv6 && test('::');
}, () => {
common.skip('The `reusePort` option is not supported');
});