1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const dgram = require('dgram'); 6 7const client = dgram.createSocket('udp4'); 8 9const buf = Buffer.allocUnsafe(256); 10 11const onMessage = common.mustSucceed((bytes) => { 12 assert.strictEqual(bytes, buf.length); 13 client.close(); 14}); 15 16client.bind(0, common.mustCall(() => { 17 client.connect(client.address().port, common.mustCall(() => { 18 client.send(buf, onMessage); 19 })); 20})); 21