mirror of
https://github.com/nodejs/node.git
synced 2024-11-25 08:19:38 +01:00
3e1b1dd4a9
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
36 lines
1022 B
JavaScript
36 lines
1022 B
JavaScript
// Testing to send an handle twice to the parent process.
|
|
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var cluster = require('cluster');
|
|
var net = require('net');
|
|
|
|
var workers = {
|
|
toStart: 1
|
|
};
|
|
|
|
if (cluster.isMaster) {
|
|
for (var i = 0; i < workers.toStart; ++i) {
|
|
var worker = cluster.fork();
|
|
worker.on('exit', function(code, signal) {
|
|
assert.equal(code, 0, 'Worker exited with an error code');
|
|
assert(!signal, 'Worker exited by a signal');
|
|
});
|
|
}
|
|
} else {
|
|
var server = net.createServer(function(socket) {
|
|
process.send('send-handle-1', socket);
|
|
process.send('send-handle-2', socket);
|
|
});
|
|
|
|
server.listen(common.PORT, function() {
|
|
var client = net.connect({ host: 'localhost', port: common.PORT });
|
|
client.on('close', function() { cluster.worker.disconnect(); });
|
|
setTimeout(function() { client.end(); }, 50);
|
|
}).on('error', function(e) {
|
|
console.error(e);
|
|
assert(false, 'server.listen failed');
|
|
cluster.worker.disconnect();
|
|
});
|
|
}
|