mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
921 B
47 lines
921 B
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
const NUM = 8;
|
|
const connections = [];
|
|
const clients = [];
|
|
let clients_counter = 0;
|
|
|
|
const server = net.createServer(function listener(c) {
|
|
connections.push(c);
|
|
}).listen(0, makeConnection);
|
|
|
|
|
|
function makeConnection() {
|
|
if (clients_counter >= NUM) return;
|
|
net.connect(server.address().port, function connected() {
|
|
clientConnected(this);
|
|
makeConnection();
|
|
});
|
|
}
|
|
|
|
|
|
function clientConnected(client) {
|
|
clients.push(client);
|
|
if (++clients_counter >= NUM)
|
|
checkAll();
|
|
}
|
|
|
|
|
|
function checkAll() {
|
|
const handles = process._getActiveHandles();
|
|
|
|
clients.forEach(function(item) {
|
|
assert.ok(handles.includes(item));
|
|
item.destroy();
|
|
});
|
|
|
|
connections.forEach(function(item) {
|
|
assert.ok(handles.includes(item));
|
|
item.end();
|
|
});
|
|
|
|
assert.ok(handles.includes(server));
|
|
server.close();
|
|
}
|
|
|