Henrik Nordstrom wrote:

> Glynn Clements wrote:
> 
> > I don't think that you should use select() on descriptors which are
> > non-blocking. You would normally either use select() or non-blocking
> > I/O, but not both.
> 
> I have to disagree here. Using select is REQUIRED when doing
> non-blocking I/O. There is no other method for waiting until data is
> available (or check which filedescriptors that have data waiting if you
> are using a zero timeout).

Using select() is required if you only want to read from a descriptor
when there is data available (e.g. because the read() would otherwise
block).

If the descriptor is non-blocking (O_NONBLOCK), read() will return -1
and set errno to EAGAIN. You don't need to check whether data is
available in order to prevent blocking.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to