Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-dgram-send-callback-buffer.js « parallel « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e877b8d73bdeb9b3bb98596dcfc4d7d7833b277b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';

const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');

const client = dgram.createSocket('udp4');

const buf = Buffer.allocUnsafe(256);

const onMessage = common.mustCall(function(err, bytes) {
  assert.equal(bytes, buf.length);
  clearTimeout(timer);
  client.close();
});

const timer = setTimeout(function() {
  throw new Error('Timeout');
}, common.platformTimeout(200));

client.send(buf, common.PORT, common.localhostIPv4, onMessage);