mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
32679c73c1
- Do not require presence of `address` parameter to use `callback` parameter; `address` is *always* optional - Improve exception messaging if `address` is invalid type - If `address` is an invalid type, guarantee a synchronously thrown exception - Update documentation to reflect signature changes - Add coverage around valid, undocumented types for `address` parameter. - Add coverage around known invalid, but uncovered, types for `address` parameter. PR-URL: https://github.com/nodejs/node/pull/10473 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
21 lines
516 B
JavaScript
21 lines
516 B
JavaScript
'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;
|
|
|
|
const onMessage = common.mustCall(function messageSent(err, bytes) {
|
|
assert.ifError(err);
|
|
assert.notStrictEqual(bytes, buf.length);
|
|
assert.strictEqual(bytes, buf.length - offset);
|
|
client.close();
|
|
});
|
|
|
|
client.send(buf, offset, len, common.PORT, onMessage);
|