• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4
5const assert = require('assert');
6const dgram = require('dgram');
7
8const client = dgram.createSocket('udp4');
9
10let interval;
11
12client.on('message', common.mustCall(function onMessage(buf, info) {
13  const expected = Buffer.alloc(0);
14  assert.ok(buf.equals(expected), `Expected empty message but got ${buf}`);
15  clearInterval(interval);
16  client.close();
17}));
18
19client.on('listening', common.mustCall(function() {
20  interval = setInterval(function() {
21    client.send([], client.address().port, common.localhostIPv4);
22  }, 10);
23}));
24
25client.bind(0);
26