mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3e1b1dd4a9
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
44 lines
854 B
JavaScript
44 lines
854 B
JavaScript
var net = require('net');
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
var timeoutCount = 0;
|
|
|
|
var server = net.createServer(function(stream) {
|
|
stream.setTimeout(100);
|
|
|
|
stream.resume();
|
|
|
|
stream.on('timeout', function() {
|
|
console.log('timeout');
|
|
// try to reset the timeout.
|
|
stream.write('WHAT.');
|
|
// don't worry, the socket didn't *really* time out, we're just thinking
|
|
// it did.
|
|
timeoutCount += 1;
|
|
});
|
|
|
|
stream.on('end', function() {
|
|
console.log('server side end');
|
|
stream.end();
|
|
});
|
|
});
|
|
|
|
server.listen(common.PORT, function() {
|
|
var c = net.createConnection(common.PORT);
|
|
|
|
c.on('data', function() {
|
|
c.end();
|
|
});
|
|
|
|
c.on('end', function() {
|
|
console.log('client side end');
|
|
server.close();
|
|
});
|
|
});
|
|
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(1, timeoutCount);
|
|
});
|