mirror of
https://github.com/nodejs/node.git
synced 2025-05-13 10:54:13 +00:00

Use the common.isWindows, common.isFreeBSD and common.isSunOS where possible. Add common.isOSX and common.isLinux. Fix `test-fs-read-file-sync-hostname` as in its current form was not being run anywhere. PR-URL: https://github.com/nodejs/node/pull/7845 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
41 lines
800 B
JavaScript
41 lines
800 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
|
|
var dgram = require('dgram');
|
|
var callbacks = 0;
|
|
var client;
|
|
var timer;
|
|
|
|
if (common.isOSX) {
|
|
common.skip('because of 17894467 Apple bug');
|
|
return;
|
|
}
|
|
|
|
client = dgram.createSocket('udp4');
|
|
|
|
client.bind(0, function() {
|
|
function callback() {
|
|
callbacks++;
|
|
if (callbacks == 2) {
|
|
clearTimeout(timer);
|
|
client.close();
|
|
} else if (callbacks > 2) {
|
|
throw new Error('the callbacks should be called only two times');
|
|
}
|
|
}
|
|
|
|
client.on('message', function(buffer, bytes) {
|
|
callback();
|
|
});
|
|
|
|
const port = this.address().port;
|
|
client.send(
|
|
Buffer.allocUnsafe(1), 0, 0, port, '127.0.0.1', (err, len) => {
|
|
callback();
|
|
});
|
|
|
|
timer = setTimeout(function() {
|
|
throw new Error('Timeout');
|
|
}, 200);
|
|
});
|