2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-01 11:57:23 -05:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const net = require('net');
|
2010-04-20 19:01:41 -04:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
let serverConnection;
|
|
|
|
let clientConnection;
|
|
|
|
const echoServer = net.createServer(function(connection) {
|
2010-04-20 19:01:41 -04:00
|
|
|
serverConnection = connection;
|
2016-12-01 11:57:23 -05:00
|
|
|
setTimeout(common.mustCall(function() {
|
2015-10-20 16:58:16 -04:00
|
|
|
// make sure both connections are still open
|
2016-12-01 11:57:23 -05:00
|
|
|
assert.strictEqual(serverConnection.readyState, 'open');
|
|
|
|
assert.strictEqual(clientConnection.readyState, 'open');
|
2015-10-20 16:58:16 -04:00
|
|
|
serverConnection.end();
|
|
|
|
clientConnection.end();
|
|
|
|
echoServer.close();
|
2016-12-01 11:57:23 -05:00
|
|
|
}, 1), common.platformTimeout(100));
|
2010-04-20 19:01:41 -04:00
|
|
|
connection.setTimeout(0);
|
2016-12-30 10:09:13 -05:00
|
|
|
assert.notStrictEqual(connection.setKeepAlive, undefined);
|
2015-08-18 11:45:59 -07:00
|
|
|
// send a keepalive packet after 50 ms
|
|
|
|
connection.setKeepAlive(true, common.platformTimeout(50));
|
2011-10-15 01:08:36 +02:00
|
|
|
connection.on('end', function() {
|
2010-04-20 19:01:41 -04:00
|
|
|
connection.end();
|
|
|
|
});
|
|
|
|
});
|
2016-05-29 03:06:56 -04:00
|
|
|
echoServer.listen(0);
|
2010-04-20 19:01:41 -04:00
|
|
|
|
2011-10-15 01:08:36 +02:00
|
|
|
echoServer.on('listening', function() {
|
2016-05-29 03:06:56 -04:00
|
|
|
clientConnection = net.createConnection(this.address().port);
|
2010-08-12 01:38:42 +02:00
|
|
|
clientConnection.setTimeout(0);
|
2010-12-04 15:20:34 -08:00
|
|
|
});
|