Created
January 3, 2011 21:25
-
-
Save wadey/763992 to your computer and use it in GitHub Desktop.
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 example attempts to time out before the connection is established | |
var net = require('net'); | |
var start = Date.now(); | |
var stream = net.createConnection(9999, 'google.com'); | |
stream.setTimeout(1000); | |
stream.on('timeout', function() { | |
console.error('timeout:', Date.now() - start); | |
stream.end(); | |
}); | |
stream.on('connect', function() { | |
console.log('connect:', Date.now() - start); | |
stream.end(); | |
}); |
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 example attempts to time out after the connection is established | |
var net = require('net'); | |
var start = Date.now(); | |
var stream = net.createConnection(80, 'google.com'); | |
stream.on('timeout', function() { | |
console.error('timeout:', Date.now() - start); | |
stream.end(); | |
}); | |
stream.on('connect', function() { | |
console.log('connect:', Date.now() - start); | |
stream.setTimeout(1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment