in reply to Re: Perl threads to open 200 http connections
in thread Perl threads to open 200 http connections

Hi Alex, after the 63 connections forking stops and following is the error. -- Cant Fork: Resource temporarily unavailable.

Below is the code -
for (my $i=0;$i<200;$i++) { my $filename = "File-10M-".$i.".txt"; FORK: { if ($pid=fork) { next; } elsif (defined $pid) { # system("wget --output-document D:\\kshare\\payload\\$filena +me http://10.2.1.23/http-path/payload/10MB/$filename >nul"); print "$filename\n"; exit; } elsif ($! eq "EAGAIN"){ redo FORK; } else { print "Cant Fork: $!"; exit 2; } } }

Replies are listed 'Best First'.
Re^3: Perl threads to open 200 http connections
by BrowserUk (Patriarch) on Aug 03, 2010 at 11:31 UTC

    The problem is the way wait is emulated. It uses a windows API that has a limit of 64 semaphores. Hence you cannot start another process until one of the existing 63 has completed.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.