jesuashok,
Actually, I am using select eg:
# Activate socket $read_handles = IO::Select->new(); $read_handles->add($cfg::listen_socket); # Main loop: check reads/accepts, check writes, check ready to pro +cess # Loop forever, listening for incoming msgs while (1) { # check for new information on the connections we have # NB: use blocking handles. ($new_read_handles) = IO::Select->select($read_handles, undef, undef +);
When I said blocking socket, I mean it's declared so that it waits on the socket instead of busy waiting round the above loop, wasting cpu.
Here's the declaration:
$cfg::listen_socket = IO::Socket::INET->new(LocalPort => $cfg::params{'RPS_P +ORT'}, Type => SOCK_STREAM, Proto => 'tcp', Listen => SOMAXCONN, Reuse => 1, Blocking => 1 ) # Blocking is +on
As I understand ALRM (which occurred to me), I was going to use it in the ctrl thread to give up waiting for the listen thr to shutdown after X seconds, but it seems to me that's more or less equiv to just ignoring the listen thr anyway, as it (listen thr) won't actually shutdown.

tye: I suppose I could use the shutdown cmd as long as I make the socket declaration threads::shared::share($cfg::listen_socket). At the moment it's only global within the listen thr.

Cheers
Chris

In reply to Re: Shutdown a thread that is using a blocking socket by chrism01
in thread Shutdown a thread that is using a blocking socket by chrism01

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.