mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:13:21 +00:00

- Replace require() vars with const. - Replace assert.equal() with assert.strictEqual(). - Add common.mustCall() to the setTimeout() callback. PR-URL: https://github.com/nodejs/node/pull/9995 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
32 lines
998 B
JavaScript
32 lines
998 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
var serverConnection;
|
|
var clientConnection;
|
|
var 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.notEqual(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);
|
|
});
|