Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm working with the code from the perl cookbook, "Pre-Forking Servers"

I'm having difficulty reading all of the data from the client. I'm using the following code, the Begin/End grab is what is catching the clients data:

for ($i=0; $i < $MAX_CLIENTS_PER_CHILD; $i++) { ($client) = $server->accept( ) or last; #Begin Grab incoming data my $data; my $rv = $client->recv($data,POSIX::BUFSIZ, 0); #End Grab print $data ."\n"; }

This, however, doesn't grab all of the data from the client. Is there a better way to handle this?

To test, I am hitting the pre-forking server with firefoxer and using the "Live HTTP headers" plugin see exactly what is being sent to the server. Many more headers are being sent than is being printed out.

Replies are listed 'Best First'.
Re: Pre-Forking Server, Reading client data
by Zaxo (Archbishop) on Aug 15, 2005 at 00:38 UTC

    I think you need to read the socket in a select loop and append $data to the previously caught messages. You are only reading a single chunk.

    After Compline,
    Zaxo

Re: Pre-Forking Server, Reading client data
by merlyn (Sage) on Aug 15, 2005 at 00:53 UTC

      Yes that's in the child after fork, Perl Cookbook Recipe 17.12 in the first edition.

      After Compline,
      Zaxo