mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

Changed var to const PR-URL: https://github.com/nodejs/node/pull/8599 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
31 lines
611 B
JavaScript
31 lines
611 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (common.isWindows) {
|
|
common.skip('on windows, because clustered dgram is ENOTSUP');
|
|
return;
|
|
}
|
|
|
|
const cluster = require('cluster');
|
|
const dgram = require('dgram');
|
|
|
|
if (cluster.isMaster) {
|
|
const unbound = cluster.fork().on('online', bind);
|
|
|
|
function bind() {
|
|
cluster.fork({BOUND: 'y'}).on('listening', disconnect);
|
|
}
|
|
|
|
function disconnect() {
|
|
unbound.disconnect();
|
|
unbound.on('disconnect', cluster.disconnect);
|
|
}
|
|
} else {
|
|
if (process.env.BOUND === 'y') {
|
|
const source = dgram.createSocket('udp4');
|
|
|
|
source.bind(0);
|
|
}
|
|
}
|