mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 14:25:18 +00:00

PR-URL: https://github.com/nodejs/node/pull/56079 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
20 lines
540 B
JavaScript
20 lines
540 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const net = require('net');
|
|
|
|
const blockList = new net.BlockList();
|
|
blockList.addAddress(common.localhostIPv4);
|
|
|
|
const server = net.createServer({ blockList }, common.mustNotCall());
|
|
server.listen(0, common.localhostIPv4, common.mustCall(() => {
|
|
const adddress = server.address();
|
|
const socket = net.connect({
|
|
localAddress: common.localhostIPv4,
|
|
host: adddress.address,
|
|
port: adddress.port
|
|
});
|
|
socket.on('close', common.mustCall(() => {
|
|
server.close();
|
|
}));
|
|
}));
|