mirror of https://github.com/nodejs/node.git
19 lines
549 B
JavaScript
19 lines
549 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const dgram = require('dgram');
|
|
const cluster = require('cluster');
|
|
|
|
if (cluster.isPrimary) {
|
|
cluster.fork();
|
|
} else {
|
|
// When the socket attempts to bind, it requests a handle from the cluster.
|
|
// Force the cluster to send back an error code.
|
|
const socket = dgram.createSocket('udp4');
|
|
cluster._getServer = function(self, options, callback) {
|
|
socket.close(() => { cluster.worker.disconnect(); });
|
|
callback(-1);
|
|
};
|
|
socket.on('error', common.mustNotCall());
|
|
socket.bind();
|
|
}
|