mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 01:35:51 +00:00

PR-URL: https://github.com/nodejs/node/pull/43497 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
26 lines
853 B
JavaScript
26 lines
853 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const server = net.createServer({
|
|
keepAlive: true,
|
|
keepAliveInitialDelay: 1000
|
|
}, common.mustCall((socket) => {
|
|
socket.destroy();
|
|
server.close();
|
|
})).listen(0, common.mustCall(() => {
|
|
net.connect(server.address().port);
|
|
}));
|
|
|
|
const onconnection = server._handle.onconnection;
|
|
server._handle.onconnection = common.mustCall((err, clientHandle) => {
|
|
const setKeepAlive = clientHandle.setKeepAlive;
|
|
clientHandle.setKeepAlive = common.mustCall((enable, initialDelayMsecs) => {
|
|
assert.strictEqual(enable, server.keepAlive);
|
|
assert.strictEqual(initialDelayMsecs, server.keepAliveInitialDelay);
|
|
setKeepAlive.call(clientHandle, enable, initialDelayMsecs);
|
|
});
|
|
onconnection.call(server._handle, err, clientHandle);
|
|
});
|