[Haskell-cafe] Re: standard poll/select interface

John Meacham john at repetae.net
Fri Feb 10 17:13:12 EST 2006

On Fri, Feb 10, 2006 at 12:26:30PM +0000, Simon Marlow wrote:
> in fact, I think this should be the basic API, since you can implement
> readFD in terms of it.  (readNonBlockingFD always reads at least one
> byte, blocking until some data is available).  This is used to partially
> fill an input buffer with the available data, for example.

this is the behavior of standard file descriptors. not non-blocking
ones. We should definitly not guarentee reads fill an input buffer
fully at least for the lowest level calls, that is the job for the
layers on top of it.

> One problem here is that in order to implement readNonBlockingFD on Unix
> you have to put the FD into O_NONBLOCK mode, which due to misdesign of
> the Unix API affects other users of the same file descriptor, including
> other programs.  GHC suffers from this problem.

non blocking ones will return immediatly if no data is available rather
than make sure they return at least one byte.

In any case, the correct solution in the circumstances is to provide a
select/poll/epoll/devpoll interface. It is nicer than setting
NON_BLOCKING and more efficient. This is largely orthogonal to the
Streams design though.


John Meacham - ⑆repetae.net⑆john⑈

More information about the Haskell-Cafe mailing list