The following message is a courtesy copy of an article
that has been posted as well.
>>>>> "Christopher" == Christopher J Farrell <farrllcj@cig.mot.com> writes:
Christopher> I was just wondering about this one.
Christopher> If a person does a select on multiple file handles and gets a results back
Christopher> saying 'yes someone is ready', is there an easy way to find out who of those
Christopher> handles are ready? Or is the only way to then do individual selects on each
Christopher> filehandle?
Christopher> I was trying to decode the $rout info but fileno() just kept coming back null.
Look at the code in chat2.pl (in the library) for &chat'select.
Briefly, I presume you understand that you *set* the bits of $rout
corresponding to the fd-numbers of the filehandles you are interested
in. When select returns, it will *clear* any bits of $rout that
aren't ready yet. What I did in &chat'select was build an assoc array
of filehandle => fd mapping, and use the mapping again to reexamine
the bits.
Also, remember that unless you use sysread() exclusively on those
filehandles, you will never get reliable select()'s, because the STDIO
buffering will get in the way.
This is why there are filehandles and there are "chathandles". I wish
it could have been better integrated, as it is in TCL/expect. <sigh>
[.note to Larry Wall and p5p: why can't 4-arg select fake up a probe
into stdio's buffers and diddle $rout appropriately? Then we could
eliminate chathandles! It would also solve a number of other paradigm
problems about read/sysread/select.]
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
# legal fund: $6493.99 collected, $112379.50 spent; email fund@stonehenge.com for details
that has been posted as well.
>>>>> "Christopher" == Christopher J Farrell <farrllcj@cig.mot.com> writes:
Christopher> I was just wondering about this one.
Christopher> If a person does a select on multiple file handles and gets a results back
Christopher> saying 'yes someone is ready', is there an easy way to find out who of those
Christopher> handles are ready? Or is the only way to then do individual selects on each
Christopher> filehandle?
Christopher> I was trying to decode the $rout info but fileno() just kept coming back null.
Look at the code in chat2.pl (in the library) for &chat'select.
Briefly, I presume you understand that you *set* the bits of $rout
corresponding to the fd-numbers of the filehandles you are interested
in. When select returns, it will *clear* any bits of $rout that
aren't ready yet. What I did in &chat'select was build an assoc array
of filehandle => fd mapping, and use the mapping again to reexamine
the bits.
Also, remember that unless you use sysread() exclusively on those
filehandles, you will never get reliable select()'s, because the STDIO
buffering will get in the way.
This is why there are filehandles and there are "chathandles". I wish
it could have been better integrated, as it is in TCL/expect. <sigh>
[.note to Larry Wall and p5p: why can't 4-arg select fake up a probe
into stdio's buffers and diddle $rout appropriately? Then we could
eliminate chathandles! It would also solve a number of other paradigm
problems about read/sysread/select.]
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
# legal fund: $6493.99 collected, $112379.50 spent; email fund@stonehenge.com for details