You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
telnet localhost 10015, the connection will be lost in 1 second
telnet locahost 10016 then telnet localhost 10015, the connection will not be lost (it means the timeout event is failed for some reason)
If you change the var "to" from string to int, the timeout will always working.
<<File: tst.js>>
var net = require('net');
var clilistener = net.createServer(function(c) {
var to = '1000';
// var to = 1000;
var mark = 'svr1:';
console.log(mark+'cli connected from '+c.remoteAddress+':'+c.remotePort);
console.log(mark+'set timeout to '+to);
c.setTimeout(to, function() {
console.log(mark+'time out arrived...');
c.destroy();
});
c.on('error', function(err) {
c.destroy();
});
c.on('close', function(isErr) {
console.log(mark+'cli out');
});
//
});
clilistener.listen(10015);
var clilistener = net.createServer(function(c) {
var to = '60000';
// var to = 60000;
var mark = 'svr1:';
console.log(mark+'cli connected from '+c.remoteAddress+':'+c.remotePort);
console.log(mark+'set timeout to '+to);
c.setTimeout(to, function() {
console.log(mark+'time out arrived...');
c.destroy();
});
c.on('error', function(err) {
c.destroy();
});
c.on('close', function(isErr) {
console.log(mark+'cli out');
});
//
});
clilistener.listen(10016);