11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst dgram = require('dgram'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst buf = Buffer.alloc(1024, 42); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst socket = dgram.createSocket('udp4'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci// Get a random port for send 101cb0ef41Sopenharmony_ciconst portGetter = dgram.createSocket('udp4') 111cb0ef41Sopenharmony_ci .bind(0, 'localhost', common.mustCall(() => { 121cb0ef41Sopenharmony_ci socket.send(buf, 0, buf.length, 131cb0ef41Sopenharmony_ci portGetter.address().port, 141cb0ef41Sopenharmony_ci portGetter.address().address); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci // If close callback is not function, ignore the argument. 171cb0ef41Sopenharmony_ci socket.close('bad argument'); 181cb0ef41Sopenharmony_ci portGetter.close(); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci socket.on('close', common.mustCall()); 211cb0ef41Sopenharmony_ci })); 22