Ben Laurie wrote:
> > > > and doesn't actually
> > > > use nonblocking sockets.
> > >
> > > It doesn't need to! It uses select instead.
> >
> > 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.
> > 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.
- Dan
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]