1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const net = require('net'); 5 6const sockets = []; 7 8const server = net.createServer(function(c) { 9 c.on('close', common.mustCall()); 10 11 sockets.push(c); 12 13 if (sockets.length === 2) { 14 assert.strictEqual(server.close(), server); 15 sockets.forEach((c) => c.resetAndDestroy()); 16 } 17}); 18 19server.on('close', common.mustCall()); 20 21assert.strictEqual(server, server.listen(0, () => { 22 net.createConnection(server.address().port) 23 .on('error', common.mustCall((error) => { 24 assert.strictEqual(error.code, 'ECONNRESET'); 25 })); 26 net.createConnection(server.address().port) 27 .on('error', common.mustCall((error) => { 28 assert.strictEqual(error.code, 'ECONNRESET'); 29 })); 30})); 31