I'm currently writing a preforking server, but I'm having problems deciding what value to give for the Listen parameter when opening the socket.

The behaviour I want is for incoming connections to be accepted until each child process is busy, but any connections after that should be rejected (i.e. no queueing).

So do I do this:

my $socket = IO::Socket::INET->new(LocalPort => 12345, Type => SOCK_STREAM, Reuse => 1, Listen => 1 );
or this:
my $socket = IO::Socket::INET->new(LocalPort => 12345, Type => SOCK_STREAM, Reuse => 1, Listen => MAX_SERVERS ); # MAX_SERVERS = total no. of child processes
I would guess at the second version, thinking that the socket is a single resource shared by the child processes. But what I don't want to happen is for each child to let MAX_SERVERS requests queue up - for this application some requests can take hours to complete, so it is better to just refuse connections when the server is busy.

Thanks in advance,

JJ


In reply to Behaviour of 'Listen' parameter in socket for preforking server by jj808

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.