1'use strict'; 2// Ensure that closing dgram sockets in 'listening' callbacks of cluster workers 3// won't throw errors. 4 5const common = require('../common'); 6const dgram = require('dgram'); 7const cluster = require('cluster'); 8if (common.isWindows) 9 common.skip('dgram clustering is currently not supported on windows.'); 10 11if (cluster.isPrimary) { 12 for (let i = 0; i < 3; i += 1) { 13 cluster.fork(); 14 } 15} else { 16 const socket = dgram.createSocket('udp4'); 17 18 socket.on('error', common.mustNotCall()); 19 20 socket.on('listening', common.mustCall(() => { 21 socket.close(); 22 })); 23 24 socket.on('close', common.mustCall(() => { 25 cluster.worker.disconnect(); 26 })); 27 28 socket.bind(0); 29} 30