blob: 68ed5f842ff13b488e67832ce54ef9c0212caf34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
'use strict';
const common = require('../common');
const assert = require('assert');
const net = require('net');
let serverConnection;
let clientConnection;
const echoServer = net.createServer(function(connection) {
serverConnection = connection;
setTimeout(common.mustCall(function() {
// make sure both connections are still open
assert.strictEqual(serverConnection.readyState, 'open');
assert.strictEqual(clientConnection.readyState, 'open');
serverConnection.end();
clientConnection.end();
echoServer.close();
}, 1), common.platformTimeout(100));
connection.setTimeout(0);
assert.notStrictEqual(connection.setKeepAlive, undefined);
// send a keepalive packet after 50 ms
connection.setKeepAlive(true, common.platformTimeout(50));
connection.on('end', function() {
connection.end();
});
});
echoServer.listen(0);
echoServer.on('listening', function() {
clientConnection = net.createConnection(this.address().port);
clientConnection.setTimeout(0);
});
|