Created
March 17, 2011 15:00
-
-
Save naneau/874467 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var host, http, ping, port, util; | |
http = require('http'); | |
util = require('util'); | |
host = '127.0.0.1'; | |
port = 10000; | |
ping = function() { | |
var request; | |
console.log("making request"); | |
request = http.request({ | |
host: host, | |
port: port, | |
path: '/ping', | |
method: 'POST' | |
}); | |
request.on('error', function(error) { | |
return console.log("Error making ping request to " + host + ":" + port + ": " + error); | |
}); | |
request.on('response', function(response) { | |
var data; | |
response.setEncoding('utf8'); | |
data = ''; | |
response.on('data', function(chunk) { | |
return data += chunk; | |
}); | |
return response.on('end', function() { | |
return console.log("Pong: " + data); | |
}); | |
}); | |
request.write('PING'); | |
return request.end(); | |
}; | |
setInterval(ping, 1000); | |
setInterval(ping, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment