in reply to Sockets: Client keeps waiting

There are two ways which come to mind immediately as to how you can change this connection behaviour.

  1. The first is to rewrite your code as a "pre-forking" server - That is, your server will fork a number of server processes ready to respond to incoming requests from a number of clients. As requests then come in, each request is handled by one of the pre-forked code threads meaning there is little latency in handling client requests.

    Not surprisingly, merlyn has already written a column employing this technique here.

  2. The second method is to accept the incoming request and make use of select to handle requests so that blocking of further incoming client requests does not occur.

     

There a number of examples of both types of server code on this site and in some of the staple Perl books including the Perl Cookbook, Advanced Perl Programming and the ever-venerable Network Programming in Perl.

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'