Ben Laurie wrote:
> > > > To avoid blocking, you *must* use nonblocking I/O even if you use select();
> > > > there's no rule saying read() and write() won't block if select()
> > > > says they won't;
> > >
> > > Yes there is!
> >
> > That's debatable.  People have been discussing this part of POSIX recently
> > on linux-kernel; see 
>http://boudicca.tux.org/hypermail/linux-kernel/2000week44/0616.html
> > In general, the only safe way to go is to consider the results of select() and
> > poll() as hints, and only call nonblocking functions based on those
> > hints, so the program does not block when the hints turn out to be wrong.
> 
> So install an OS that works properly :-)

The discussion isn't about Linux; it's about the Posix definition of
poll() and select().  Whatever, though.  It's a bit of an academic question,
and if you want to always believe what poll() and select() tell you,
that's great as long as it works.
 
> > > > select() can occasionally be wrong, or there might
> > > > not be as many bytes available or writable as you expect.  In this program,
> > > > the call
> > > >    read(0, buf, sizeof buf)
> > > > may well block in normal operation -- what if 1024 bytes aren't
> > > > available?
> > >
> > > Then you get what is available.
> >
> > Because you're not using a nonblocking socket, the read()
> > blocks until the number of requested bytes become available.
> >
> > You would "get what is available" only if you set the socket into
> > nonblocking mode.
> 
> That is simply not true. The state machine sample would not work AT ALL
> if that were the case. But like I say, go ahead, make them non-blocking.
> Suits me.

? You're saying that, simply because select() said a file was readable,
that you can read 1024 bytes from it without blocking.

I must be missing something.

- Dan
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to