Skip to content

Instantly share code, notes, and snippets.

@naneau
Created March 17, 2011 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naneau/874467 to your computer and use it in GitHub Desktop.
Save naneau/874467 to your computer and use it in GitHub Desktop.
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