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