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.

45 lines
868 B

'use strict';
var net = require('net');
var common = require('../common');
var assert = require('assert');
var timeoutCount = 0;
14 years ago
var server = net.createServer(function(stream) {
stream.setTimeout(100);
stream.resume();
14 years ago
stream.on('timeout', function() {
console.log('timeout');
// try to reset the timeout.
14 years ago
stream.write('WHAT.');
// don't worry, the socket didn't *really* time out, we're just thinking
// it did.
timeoutCount += 1;
});
14 years ago
stream.on('end', function() {
console.log('server side end');
stream.end();
});
});
server.listen(common.PORT, function() {
var c = net.createConnection(common.PORT);
14 years ago
c.on('data', function() {
c.end();
});
14 years ago
c.on('end', function() {
console.log('client side end');
server.close();
});
});
14 years ago
process.on('exit', function() {
assert.equal(1, timeoutCount);
});