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