mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
2d7fa3d741
* Replace var's with const and let * Replace boolean flags with common.mustCall() * Using stricter comparisons * Fixed typo in comment PR-URL: https://github.com/nodejs/node/pull/8458 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
25 lines
659 B
JavaScript
25 lines
659 B
JavaScript
'use strict';
|
|
// This test binds to one port, then attempts to start a server on that
|
|
// port. It should be EADDRINUSE but be able to then bind to another port.
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const server1 = net.Server();
|
|
|
|
const server2 = net.Server();
|
|
|
|
server2.on('error', common.mustCall(function(e) {
|
|
assert.strictEqual(e.code, 'EADDRINUSE');
|
|
|
|
server2.listen(0, common.mustCall(function() {
|
|
server1.close();
|
|
server2.close();
|
|
}));
|
|
}));
|
|
|
|
server1.listen(0, common.mustCall(function() {
|
|
// This should make server2 emit EADDRINUSE
|
|
server2.listen(this.address().port);
|
|
}));
|