mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +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
668 B
JavaScript
35 lines
668 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
var tls = require('tls');
|
|
|
|
var fs = require('fs');
|
|
var net = require('net');
|
|
|
|
var options = {
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
|
|
};
|
|
|
|
var server = tls.createServer(options, function(s) {
|
|
s.write('welcome!\n');
|
|
s.pipe(s);
|
|
});
|
|
|
|
server.listen(0, function() {
|
|
var c = net.createConnection(this.address().port);
|
|
|
|
c.on('connect', function() {
|
|
c.write('blah\nblah\nblah\n');
|
|
});
|
|
|
|
c.on('end', function() {
|
|
server.close();
|
|
});
|
|
|
|
});
|