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'


In reply to Re: Sockets by rob_au
in thread Sockets: Client keeps waiting by toadi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.