Using select(2)

Dear,

using the following:

 my($scount, $stime)=
 CORE::select( $read_bits,
                $write_bits,
                $err_bits, 1);

In my program, $scount is allways equal to -1,
and $read_bits, $write_bits, $err_bits, to 0.

Does anybody know in wich case it can happen?

thank's in advance
memyself_ [ So, 30 Januar 2005 14:56 ] [ ID #616378 ]

Re: Using select(2)

memyself_ wrote:

> my($scount, $stime)=
> CORE::select( $read_bits,
> $write_bits,
> $err_bits, 1);
>
> In my program, $scount is allways equal to -1,
> and $read_bits, $write_bits, $err_bits, to 0.

You did not show us where you were setting $read_bits and such
to be nonzero. You have to set them before each time select()
is called.

$rb = one bit for each file handle you will be reading from
$wb = one bit for each file handle you will be writing to
$eb = $rb | $wb;
$ms = 1.0; # seconds for the timeout
($scount,$stime) = select( $read_bits=$rb, $write_bits=$wb,
$error_bits=$eb, $ms);
warn "Invalid arguments presented to select()" if $scount < 0;
if ($scount == 0) {
print "No file handles are ready for I/O\n";
} else {
print "Can do I/O: r=$read_bits w=$write_bits e=$error_bits\n";
}
print "$stime seconds left before timeout\n" if $stime;

Use 'perldoc -f select' for more info.
Use comp.lang.perl.misc (and not comp.lang.perl) next time.
-Joe
Joe Smith [ Mo, 31 Januar 2005 20:16 ] [ ID #618724 ]
Perl » alt.perl » Using select(2)

Vorheriges Thema: CGI problems
Nächstes Thema: WTB: Shopping Cart Software