I've been playing with UDP lately... you might be able to use the alarm function, like this:
# 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;
}
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.
Chris
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.