in reply to Checking for no traffic on a port
I put the server code in place but I don't have my client code in front of me to make sure the server doesn't execute that block even though its getting connections. In theory it should work though :) and if you don't receive something for 5 minutes it will execute the sig alarm block at the top. Hope that helps.# initialize your IO::Socket etc... $SIG{ALRM} = sub { # code here to do something interesting # if your program isn't getting + # connections } my $minutes_to_wait = 5; # wait five minutes my $alarm_seconds = $minutes_to_wait * 60; alarm $alarm_seconds; # set the first alarm while($server->recv($msg,$MAX_LEN) { # if we're here we got something # do some interesting stuff with the message #reset the alarm alarm $alarm_seconds; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Checking for no traffic on a port
by Ugmo (Initiate) on Mar 25, 2002 at 22:08 UTC |