in reply to Re: Timeouts: Any alternative to alarm in Win32?
in thread Timeouts: Any alternative to alarm in Win32?
$handle is a socket, right?
Is there any advantage to
my $state = 1; ioctl( $handle, 0x8004667e, \$state ); my $end = time() + $timeout; while( time() < $end and $buffer !~ m[\n] ) { my $read = sysread( $handle, $buffer, 100, length( $buffer ) ); sleep 1; } $state = 0; ioctl( $handle, 0x8004667e, \$state );
over
my $sel = IO::Select->new($handle); my $end = time() + $timeout; while( $buffer !~ m[\n] ) { my $left = $end - time(); last if $left <= 0; last if !$sel->can_read($left); my $read = sysread( $handle, $buffer, 100, length( $buffer ) ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Timeouts: Any alternative to alarm in Win32?
by BrowserUk (Patriarch) on Dec 04, 2008 at 01:22 UTC | |
by ikegami (Patriarch) on Dec 04, 2008 at 12:27 UTC | |
by Anonymous Monk on Sep 01, 2009 at 10:34 UTC |