Using select(2)

Using select(2)

am 30.01.2005 14:56:56 von memyself_

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

Re: Using select(2)

am 31.01.2005 20:16:42 von Joe Smith

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