2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2014-07-02 15:24:17 +02:00
|
|
|
|
2016-05-17 12:36:54 +02:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
2014-07-02 15:24:17 +02:00
|
|
|
|
2016-05-17 12:36:54 +02:00
|
|
|
const dgram = require('dgram');
|
|
|
|
const client = dgram.createSocket('udp4');
|
2014-07-02 15:24:17 +02:00
|
|
|
|
2016-05-17 12:36:54 +02:00
|
|
|
const buf = Buffer.allocUnsafe(256);
|
|
|
|
const offset = 20;
|
|
|
|
const len = buf.length - offset;
|
2014-07-02 15:24:17 +02:00
|
|
|
|
2016-05-17 12:36:54 +02:00
|
|
|
const messageSent = common.mustCall(function messageSent(err, bytes) {
|
2017-02-17 13:40:31 -08:00
|
|
|
assert.ifError(err);
|
2016-10-19 15:57:00 -07:00
|
|
|
assert.notStrictEqual(bytes, buf.length);
|
|
|
|
assert.strictEqual(bytes, buf.length - offset);
|
2015-05-19 13:00:06 +02:00
|
|
|
client.close();
|
2014-07-02 15:24:17 +02:00
|
|
|
});
|
|
|
|
|
2016-05-17 12:36:54 +02:00
|
|
|
client.send(buf, offset, len, common.PORT, '127.0.0.1', messageSent);
|