I am creating a server that needs to take the following steps in the parent thread:

  1. Check whether or not there is a client looking to connect on the local instance of IO::Socket::UNIX by calling my $SOCK = $socket->accept($socket);
  2. If there is anyone around looking to connect, connect them, fork, and create pipes to keep in touch with the parent
  3. If nobody needs to connect then send data to the children through a pipe that it opened up.

The problem I am having is that IO::Socket::accept blocks, so it will always return true. That is to say, if I call it, the program will "pause" until a client connects (even with autoflush true). I want to test whether or not there is anybody looking to connect before accepting a connection. Is this possible? I've googled and read every POD I can find on Sockets and IPC and still can't seem to find a suitable function.

Many thanks in advance,

Vautrin


Want to support the EFF and FSF by buying cool stuff? Click here.

In reply to Checking whether or not IO::Socket::accept will block by Vautrin

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.