node/test/parallel/test-dgram-send-callback-buffer-empty-address.js
Artur Vieira 4c847347c3 test: replace common.PORT in dgram test
Replace common.PORT with available port assigned by the operating
system in test-dgram-send-callback-buffer-empty-address.

PR-URL: https://github.com/nodejs/node/pull/12929
Refs: https://github.com/nodejs/node/issues/12376
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-05-22 08:38:57 +02:00

18 lines
418 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 onMessage = common.mustCall(function(err, bytes) {
assert.ifError(err);
assert.strictEqual(bytes, buf.length);
client.close();
});
client.bind(0, () => client.send(buf, client.address().port, onMessage));