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.mustCall(function(err, bytes) { 12 assert.ifError(err); 13 assert.strictEqual(bytes, buf.length); 14 client.close(); 15}); 16 17client.bind(0, common.mustCall(() => { 18 client.connect(client.address().port, common.mustCall(() => { 19 client.send(buf, onMessage); 20 })); 21})); 22