mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 12:03:30 +00:00

This helps to prevent issues where a failed test can keep a bound socket open long enough to cause other tests to fail with EADDRINUSE because the same port number is used. PR-URL: https://github.com/nodejs/node/pull/7045 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
35 lines
723 B
JavaScript
35 lines
723 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
var net = require('net');
|
|
var closed = false;
|
|
|
|
var server = net.createServer(function(s) {
|
|
console.error('SERVER: got connection');
|
|
s.end();
|
|
});
|
|
|
|
server.listen(0, function() {
|
|
var c = net.createConnection(this.address().port);
|
|
c.on('close', function() {
|
|
console.error('connection closed');
|
|
assert.strictEqual(c._handle, null);
|
|
closed = true;
|
|
assert.doesNotThrow(function() {
|
|
c.setNoDelay();
|
|
c.setKeepAlive();
|
|
c.bufferSize;
|
|
c.pause();
|
|
c.resume();
|
|
c.address();
|
|
c.remoteAddress;
|
|
c.remotePort;
|
|
});
|
|
server.close();
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert(closed);
|
|
});
|