summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-listening-port.js
blob: 40d66065d947cef33aff12cea88ccb41b62d1a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

if (cluster.isMaster) {
  cluster.fork();
  cluster.on('listening', common.mustCall(function(worker, address) {
    const port = address.port;
    // Ensure that the port is not 0 or null
    assert(port);
    // Ensure that the port is numerical
    assert.strictEqual(typeof port, 'number');
    worker.kill();
  }));
} else {
  net.createServer(common.mustNotCall()).listen(0);
}