LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-14-2009, 10:46 AM   #1
DEF.
Member
 
Registered: Apr 2009
Posts: 96

Rep: Reputation: 23
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?
 
Old 10-14-2009, 11:37 AM   #2
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
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().
 
Old 10-14-2009, 01:15 PM   #3
DEF.
Member
 
Registered: Apr 2009
Posts: 96

Original Poster
Rep: Reputation: 23
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Poll: (Without the poll) - How is Linux used in your workplace? SlowCoder General 13 09-11-2007 11:03 PM
Poll: Do you think the US is right? WindowsBurner General 198 01-06-2004 02:15 PM
Poll itsjvivek Linux - General 0 12-10-2002 10:18 PM
A Poll ! super_me General 1 06-08-2002 06:24 AM
Poll eraser LQ Suggestions & Feedback 4 08-10-2000 01:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration