LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Why poll() on a read() ? (https://www.linuxquestions.org/questions/programming-9/why-poll-on-a-read-761862/)

DEF. 10-14-2009 10:46 AM

Why poll() on a read() ?
 
Why poll() on a read() when you can just set the read() for non-blocking? What are the advantages and disadvantages of both approaches?

wje_lq 10-14-2009 11:37 AM

poll() (as well as select(), which I prefer instead) is useful if you wish to check more than one file descriptor at the same time, or even wait until one of them is ready for a read.

Otherwise, non-blocking I/O is quite adequate and you don't need poll().

DEF. 10-14-2009 01:15 PM

Thanks for your comments.

As an additional comment, I read that poll() is superior to select() in terms of it doesn't start at the first file descriptor in the system and check all of the descriptors up to the one you are interested in. However I also read that poll() is less portable as it is newer than select() and also it's timeout granularity is less.

Are these points valid?


All times are GMT -5. The time now is 10:42 AM.