• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --test-udp-no-try-send
2'use strict';
3const common = require('../common');
4const assert = require('assert');
5const dgram = require('dgram');
6
7const socket = dgram.createSocket('udp4');
8assert.strictEqual(socket.getSendQueueSize(), 0);
9assert.strictEqual(socket.getSendQueueCount(), 0);
10socket.close();
11
12const server = dgram.createSocket('udp4');
13const client = dgram.createSocket('udp4');
14
15server.bind(0, common.mustCall(() => {
16  client.connect(server.address().port, common.mustCall(() => {
17    const data = 'hello';
18    client.send(data);
19    client.send(data);
20    // See uv__send in win/udp.c
21    assert.strictEqual(client.getSendQueueSize(),
22                       common.isWindows ? 0 : data.length * 2);
23    assert.strictEqual(client.getSendQueueCount(), 2);
24    client.close();
25    server.close();
26  }));
27}));
28