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