Skip to content

Instantly share code, notes, and snippets.

@brianseeders
Created May 20, 2013 20:30
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 brianseeders/4f93615c1182e7d76956 to your computer and use it in GitHub Desktop.
Save brianseeders/4f93615c1182e7d76956 to your computer and use it in GitHub Desktop.
var http = require('http');
var url_module = require('url');
var concurrency = 50;
var request_url = 'http://162.209.11.173';
var count = 0;
for(var i = 0; i < concurrency; i++)
{
make_request(request_url);
}
function make_request(url)
{
try
{
var parsed_url = url_module.parse(url);
var options = {
hostname: parsed_url.hostname,
port: parsed_url.port,
path: parsed_url.path,
method: 'GET',
agent: false
};
var req;
req = http.request(options, function(res) {
make_request(url);
count++;
console.log(count+' requests');
// req.socket.destroy();
}).on('error', function(e) {
console.log(e);
make_request(url);
});
req.end();
}
catch(exception)
{
console.log(exception);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment