Dan Kegel wrote:
> 
> 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.

So install an OS that works properly :-)

> > > 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.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit."

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

Reply via email to