Errto has asked for the wisdom of the Perl Monks concerning the following question:
Greetings,
I have a program that accepts socket connections with IO::Socket (or rather its subclass HTTP::Daemon). Because this program is also checking for user input, I'm using a timeout on the accept call. But it appears that the minimum timeout is 1 second. In the interest of responsiveness to picky users, I'd like to make it shorter if I could (maybe 0.25 or 0.5 sec). Is there a way to do this, or some creative workaround I could employ instead? My current code looks roughly like:
I'm running on Win32 ActivePerl 5.8.6 in case it matters.my $d = HTTP::Daemon->new ( LocalAddr => 'localhost', LocalPort => 1244 ) or die; $d->timeout(1); MAIN_LOOP: while (1) { my $c = $d->accept; unless (defined $c) { do_other_stuff(); next MAIN_LOOP; } process_request($c); }
Update: I am on crack. saintmike is correct. I don't know why I thought otherwise (or why I didn't retest one last time). saintmike++.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: short (<1sec) timeout on IO::Socket
by saintmike (Vicar) on Aug 29, 2005 at 22:14 UTC | |
by Errto (Vicar) on Aug 29, 2005 at 23:10 UTC | |
by pg (Canon) on Aug 30, 2005 at 03:01 UTC |