mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

dgram#send callback was changed synchronously. The PR-URL is here https://github.com/joyent/libuv/pull/1358 This commit is temporary fix until libuv issue is resolved. https://github.com/libuv/libuv/issues/301 PR-URL: https://github.com/iojs/io.js/pull/1313 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
38 lines
770 B
JavaScript
38 lines
770 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const dgram = require('dgram');
|
|
const client = dgram.createSocket('udp4');
|
|
const chunk = 'abc';
|
|
var recursiveCount = 0;
|
|
var received = 0;
|
|
const limit = 10;
|
|
|
|
function onsend() {
|
|
if (recursiveCount > limit) {
|
|
throw new Error('infinite loop detected');
|
|
}
|
|
if (received < limit) {
|
|
client.send(
|
|
chunk, 0, chunk.length, common.PORT, common.localhostIPv4, onsend);
|
|
}
|
|
recursiveCount++;
|
|
}
|
|
|
|
client.on('listening', function() {
|
|
onsend();
|
|
});
|
|
|
|
client.on('message', function(buf, info) {
|
|
received++;
|
|
if (received === limit) {
|
|
client.close();
|
|
}
|
|
});
|
|
|
|
client.on('close', common.mustCall(function() {
|
|
assert.equal(received, limit);
|
|
}));
|
|
|
|
client.bind(common.PORT);
|