• 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.mustSucceed(function messageSent(bytes) {
14  assert.notStrictEqual(bytes, buf.length);
15  assert.strictEqual(bytes, buf.length - offset);
16  client.close();
17});
18
19client.bind(0, () => client.send(buf, offset, len,
20                                 client.address().port,
21                                 onMessage));
22