This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue https://github.com/ry/node/issues/issue/481
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
}); |
See https://github.com/ry/node/issues/issue/481/