summaryrefslogtreecommitdiff
path: root/test/parallel/test-dgram-listen-after-bind.js
blob: e60687649cda301dbeac8e7f5f308dff31d6ccf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
require('../common');
const assert = require('assert');
const dgram = require('dgram');

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

socket.bind();

let fired = false;
const timer = setTimeout(function() {
  socket.close();
}, 100);

socket.on('listening', function() {
  clearTimeout(timer);
  fired = true;
  socket.close();
});

socket.on('close', function() {
  assert(fired, 'listening should fire after bind');
});