blob: c1b46ac53ea6e6c5d644aa7acebe91ed6da3dc4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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.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);
});
|