• 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.allocUnsafe(256);
10const offset = 20;
11const len = buf.length - offset;
12
13const messageSent = 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, common.mustCall(() => {
21  client.connect(client.address().port, common.mustCall(() => {
22    client.send(buf, offset, len, messageSent);
23  }));
24}));
25