1'use strict'; 2const common = require('../common'); 3const dgram = require('dgram'); 4 5// Regression test for https://github.com/nodejs/node/issues/30209 6// No warning should be emitted when re-trying `.bind()` on UDP sockets 7// repeatedly. 8 9process.on('warning', common.mustNotCall()); 10 11const reservePortSocket = dgram.createSocket('udp4'); 12reservePortSocket.bind(() => { 13 const { port } = reservePortSocket.address(); 14 15 const newSocket = dgram.createSocket('udp4'); 16 17 let errors = 0; 18 newSocket.on('error', common.mustCall(() => { 19 if (++errors < 20) { 20 newSocket.bind(port, common.mustNotCall()); 21 } else { 22 newSocket.close(); 23 reservePortSocket.close(); 24 } 25 }, 20)); 26 newSocket.bind(port, common.mustNotCall()); 27}); 28