1'use strict'; 2const common = require('../common'); 3if (common.isWindows) 4 common.skip('dgram clustering is currently not supported on windows.'); 5 6const assert = require('assert'); 7const cluster = require('cluster'); 8const dgram = require('dgram'); 9 10if (cluster.isPrimary) { 11 cluster.fork().on('exit', common.mustCall((code) => { 12 assert.strictEqual(code, 0); 13 })); 14 return; 15} 16 17let waiting = 2; 18function close() { 19 if (--waiting === 0) 20 cluster.worker.disconnect(); 21} 22 23const options = { type: 'udp4', reuseAddr: true }; 24const socket1 = dgram.createSocket(options); 25const socket2 = dgram.createSocket(options); 26 27socket1.bind(0, () => { 28 socket2.bind(socket1.address().port, () => { 29 // Work around health check issue 30 process.nextTick(() => { 31 socket1.close(close); 32 socket2.close(close); 33 }); 34 }); 35}); 36