2016-05-17 12:36:54 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
|
2016-11-21 11:05:24 -08:00
|
|
|
const assert = require('assert');
|
|
|
|
const dgram = require('dgram');
|
|
|
|
|
2016-05-17 12:36:54 +02:00
|
|
|
const client = dgram.createSocket('udp4');
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
let interval;
|
2016-11-21 11:05:24 -08:00
|
|
|
|
2016-05-17 12:36:54 +02:00
|
|
|
client.on('message', common.mustCall(function onMessage(buf, info) {
|
|
|
|
const expected = Buffer.alloc(0);
|
2017-10-06 10:58:33 -07:00
|
|
|
assert.ok(buf.equals(expected), `Expected empty message but got ${buf}`);
|
2016-11-21 11:05:24 -08:00
|
|
|
clearInterval(interval);
|
2016-05-17 12:36:54 +02:00
|
|
|
client.close();
|
|
|
|
}));
|
|
|
|
|
2016-11-21 11:05:24 -08:00
|
|
|
client.on('listening', common.mustCall(function() {
|
|
|
|
interval = setInterval(function() {
|
|
|
|
client.send([], client.address().port, common.localhostIPv4);
|
|
|
|
}, 10);
|
|
|
|
}));
|
2016-05-17 12:36:54 +02:00
|
|
|
|
2016-05-29 03:06:56 -04:00
|
|
|
client.bind(0);
|