in reply to Shutdown a thread that is using a blocking socket

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

Replies are listed 'Best First'.
Re^2: Shutdown a thread that is using a blocking socket
by chrism01 (Friar) on Mar 30, 2006 at 23:20 UTC
    Interestingly, even though I can't (perl won't let me) threads::shared::share($cfg::listen_socket), (because it's too complex an object), declaring it in the ctrl thread then assigning/using it in the listen thr still allows the shutdown() cmd from the ctrl thr to affect the listen thr, which is what I wanted. :-)

    Cheers
    Chris