mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
905 B
44 lines
905 B
// socket.write was not resetting the timeout timer. See
|
|
// https://github.com/joyent/node/issues/2002
|
|
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var net = require('net');
|
|
|
|
var seconds = 5;
|
|
var gotTimeout = false;
|
|
var counter = 0;
|
|
|
|
var server = net.createServer(function(socket) {
|
|
socket.setTimeout((seconds / 2) * 1000, function() {
|
|
gotTimeout = true;
|
|
console.log('timeout!!');
|
|
socket.destroy();
|
|
process.exit(1);
|
|
});
|
|
|
|
var interval = setInterval(function() {
|
|
counter++;
|
|
|
|
if (counter == seconds) {
|
|
clearInterval(interval);
|
|
server.close();
|
|
socket.destroy();
|
|
}
|
|
|
|
if (socket.writable) {
|
|
socket.write(Date.now() + '\n');
|
|
}
|
|
}, 1000);
|
|
});
|
|
|
|
|
|
server.listen(common.PORT, function() {
|
|
var s = net.connect(common.PORT);
|
|
s.pipe(process.stdout);
|
|
});
|
|
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(false, gotTimeout);
|
|
});
|
|
|