2017-01-12 22:10:26 -08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const dgram = require('dgram');
|
|
|
|
const client = dgram.createSocket('udp4');
|
|
|
|
|
|
|
|
const buf = Buffer.alloc(256, 'x');
|
|
|
|
const offset = 20;
|
|
|
|
const len = buf.length - offset;
|
|
|
|
|
2020-09-06 22:27:07 +02:00
|
|
|
const onMessage = common.mustSucceed(function messageSent(bytes) {
|
2017-01-12 22:10:26 -08:00
|
|
|
assert.notStrictEqual(bytes, buf.length);
|
|
|
|
assert.strictEqual(bytes, buf.length - offset);
|
|
|
|
client.close();
|
|
|
|
});
|
|
|
|
|
2017-05-10 03:45:13 +00:00
|
|
|
client.bind(0, () => client.send(buf, offset, len,
|
|
|
|
client.address().port,
|
|
|
|
onMessage));
|