select
select rbits, wbits, ebits, timeout
- The four-argument
selectoperator is totally unrelated to the previously describedselectoperator. This operator is for discovering which (if any) of your file descriptors are ready to do input or output, or to report an exceptional condition. It calls theselect(2)system call with the bitmasks you've specified, which you can construct usingfilenoandvec, like this:
$rbits = $wbits = $ebits = ""; vec($rbits, fileno(STDIN), 1) = 1; vec($wbits, fileno(STDOUT), 1) = 1; $ein = $rin | $win;
Theselectcall blocks until one or more file descriptors is ready for reading, writing, or reporting an error condition. timeout is given in seconds and tellsselecthow long to wait.