Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Parallel::ForkManager or something like that?

by Sascha2018 (Acolyte)
on Aug 12, 2017 at 13:03 UTC ( [id://1197307]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Parallel::ForkManager or something like that?
in thread Parallel::ForkManager or something like that?

Now it works :) And how can i solve it that the processes are not blocking? If i open the address and port through the browser and open another browser where i connect to it, i can see the page only in one windows, till i close the browser. Then i can see the other page. Regards
  • Comment on Re^3: Parallel::ForkManager or something like that?

Replies are listed 'Best First'.
Re^4: Parallel::ForkManager or something like that?
by zentara (Archbishop) on Aug 12, 2017 at 13:34 UTC
Re^4: Parallel::ForkManager or something like that?
by marioroy (Prior) on Aug 13, 2017 at 05:36 UTC

    Hi Sascha2018. Run $pm->start before $select->add.

    while (!$die) { foreach my $key ($select->can_read()) { # foreach if ($key eq $server) { # if $bay eq $server next if $key eq ""; my $bay = $server->accept or next; my $ip = $bay->peerhost(); my $ident = _uid(); $lkup{$ident} = $bay; $pm->start($ident) and next; # <-- spawn worker here $select->add($bay); my $buffer = <$bay>; if ($buffer =~ m/^GET\s\/\sHTTP\/1\.1/) { print "OK"; sendHeader($bay); my $html=<<"EOT"; <html> <head> </head> <body style='background-color: blue'> </body> </html> EOT $bay->syswrite($html); } print "$buffer\n"; $pm->finish(0, { ip => $ip }); } } $pm->wait_all_children; }

    Regards, Mario

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1197307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found