mirror of https://github.com/lukechilds/node.git
Browse Source
PR-URL: https://github.com/nodejs/node/pull/15097 Fixes: https://github.com/nodejs/node/issues/15084 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>canary-base
committed by
Ruben Bridgewater
2 changed files with 49 additions and 14 deletions
@ -0,0 +1,26 @@ |
|||
'use strict'; |
|||
|
|||
// This tests that net.connect() from a used local port throws EADDRINUSE.
|
|||
|
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const net = require('net'); |
|||
|
|||
const server1 = net.createServer(common.mustNotCall()); |
|||
server1.listen(0, common.localhostIPv4, common.mustCall(() => { |
|||
const server2 = net.createServer(common.mustNotCall()); |
|||
server2.listen(0, common.localhostIPv4, common.mustCall(() => { |
|||
const client = net.connect({ |
|||
host: common.localhostIPv4, |
|||
port: server1.address().port, |
|||
localAddress: common.localhostIPv4, |
|||
localPort: server2.address().port |
|||
}, common.mustNotCall()); |
|||
|
|||
client.on('error', common.mustCall((err) => { |
|||
assert.strictEqual(err.code, 'EADDRINUSE'); |
|||
server1.close(); |
|||
server2.close(); |
|||
})); |
|||
})); |
|||
})); |
Loading…
Reference in new issue