For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > January 2006 > Re: [SOLVED] IO::Select->can_read returns immediately









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SOLVED] IO::Select->can_read returns immediately
delink@gmail.com

2006-01-28, 6:58 pm

Jim Gibson wrote:
> In article <slrndtkfhp.asg.glenn-nntp@ziegchen.delink.net>, Brian T
> Glenn <glenn-nntp@this.delink.is.net.invalid> wrote:
>
[snip code][color=darkred]
>
> Yes, since can_read is not blocking, there must be data ready to read
> on the FIFO. If you don't actually read the data from the FIFO, then it
> will still be ready the next time you call can_read. Try reading the
> data:
>
> print <$fh>;


This was my problem. In my quick attempt to test the loop, I forgot to
actually read the data, causing it to spin. Thanks for pointing out the
seemingly obvious to me.

>
> can_read will either return an empty list or a list with $fifo as its
> only element. There is no way you can ever print "Receiving a message
> from another source".


It is actually possible in the grand scheme of the code as extra
filehandles will be added as messages come into the FIFO, but the way
it is currently written, that is correct.

Thank you for the help,

Brian

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com