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
|