• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const dgram = require('dgram');
6
7const client = dgram.createSocket('udp4');
8
9const buf = Buffer.allocUnsafe(256);
10
11const onMessage = common.mustCall(function(err, bytes) {
12  assert.ifError(err);
13  assert.strictEqual(bytes, buf.length);
14  client.close();
15});
16
17client.bind(0, () => client.send(buf,
18                                 client.address().port,
19                                 common.localhostIPv4,
20                                 onMessage));
21