mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
d12d8cd578
PR-URL: https://github.com/nodejs/node/pull/46587 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
31 lines
777 B
JavaScript
31 lines
777 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const sockets = [];
|
|
|
|
const server = net.createServer(function(c) {
|
|
c.on('close', common.mustCall());
|
|
|
|
sockets.push(c);
|
|
|
|
if (sockets.length === 2) {
|
|
assert.strictEqual(server.close(), server);
|
|
sockets.forEach((c) => c.resetAndDestroy());
|
|
}
|
|
});
|
|
|
|
server.on('close', common.mustCall());
|
|
|
|
assert.strictEqual(server, server.listen(0, () => {
|
|
net.createConnection(server.address().port)
|
|
.on('error', common.mustCall((error) => {
|
|
assert.strictEqual(error.code, 'ECONNRESET');
|
|
}));
|
|
net.createConnection(server.address().port)
|
|
.on('error', common.mustCall((error) => {
|
|
assert.strictEqual(error.code, 'ECONNRESET');
|
|
}));
|
|
}));
|