summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-disconnect-unshared-udp.js
blob: a40c386918b1565fac99b7ffcf427d7ea372e9c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if (process.platform === 'win32') {
  console.log('skipping test on windows, where clustered dgram is ENOTSUP');
  process.exit(0);
}

var cluster = require('cluster');
var dgram = require('dgram');

if (cluster.isMaster) {
  var unbound = cluster.fork().on('online', bind);

  function bind() {
    cluster.fork({BOUND: 'y'}).on('listening', disconnect);
  }

  function disconnect() {
    unbound.disconnect();
    unbound.on('disconnect', cluster.disconnect);
  }
} else {
  if (process.env.BOUND === 'y') {
    var source = dgram.createSocket('udp4');

    source.bind(0);
  }
}