On May 22, 02014, at 4:33, Nuno Barros <[email protected]> wrote:
> yes i need them to stay keepalive state, my objective is to create 100 http > conectins if no error is given + 100 till i can check a max of nat ports in a > router That doesn’t sound like you need keepalive state, just open sockets. On May 22, 02014, at 5:53, Nuno Barros <[email protected]> wrote: > > in the moment i got this, not really sure if its keeping the connection open > and the node i'am using is v0.10.28 > > var http = require('http'); > > var http_options = { > hostname: '193.136.212.161', > port: 80, > path: '/', > method: 'GET', > agent: false, > headers: { > 'Connection':'keep-alive' > } > }; > > http.request(http_options, function(res) { > }).on("socket", function (socket) { > socket.on('connect', function(res, socket, head) { > console.log('got connected!'); > }); > }); That’s probably not what you want. You don’t want to use GET (No body, whole request is sent and then socket can be closed) try something like so: http_options.method = ‘POST’; var req = http.request({method: ‘POST’, path: ‘/‘, agent: false, hostname: ‘193.136.212.161’}, function (res) {}); setTimeout(function () { req.end(‘.’); }, 10000); That should start the request right away but not complete it for ten seconds.
signature.asc
Description: Message signed with OpenPGP using GPGMail
