2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2010-12-04 15:20:34 -08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
|
|
|
var net = require('net');
|
2010-04-20 19:01:41 -04:00
|
|
|
|
|
|
|
var serverConnection;
|
2010-12-05 01:45:52 +03:00
|
|
|
var echoServer = net.createServer(function(connection) {
|
2010-04-20 19:01:41 -04:00
|
|
|
serverConnection = connection;
|
|
|
|
connection.setTimeout(0);
|
2010-12-05 22:15:30 +03:00
|
|
|
assert.notEqual(connection.setKeepAlive, undefined);
|
2010-04-20 19:01:41 -04:00
|
|
|
// send a keepalive packet after 1000 ms
|
2010-12-05 22:15:30 +03:00
|
|
|
connection.setKeepAlive(true, 1000);
|
2011-10-15 01:08:36 +02:00
|
|
|
connection.on('end', function() {
|
2010-04-20 19:01:41 -04:00
|
|
|
connection.end();
|
|
|
|
});
|
|
|
|
});
|
2010-07-15 11:47:25 -07:00
|
|
|
echoServer.listen(common.PORT);
|
2010-04-20 19:01:41 -04:00
|
|
|
|
2011-10-15 01:08:36 +02:00
|
|
|
echoServer.on('listening', function() {
|
2010-08-12 01:38:42 +02:00
|
|
|
var clientConnection = net.createConnection(common.PORT);
|
|
|
|
clientConnection.setTimeout(0);
|
2010-04-20 19:01:41 -04:00
|
|
|
|
2010-12-05 22:15:30 +03:00
|
|
|
setTimeout(function() {
|
2010-08-12 01:38:42 +02:00
|
|
|
// make sure both connections are still open
|
2010-12-05 22:15:30 +03:00
|
|
|
assert.equal(serverConnection.readyState, 'open');
|
|
|
|
assert.equal(clientConnection.readyState, 'open');
|
2010-08-12 01:38:42 +02:00
|
|
|
serverConnection.end();
|
|
|
|
clientConnection.end();
|
|
|
|
echoServer.close();
|
|
|
|
}, 1200);
|
2010-12-04 15:20:34 -08:00
|
|
|
});
|