> I don't know what is supposed to happen in theory, but
> in practice I have found select() to be quite a
> disaster in informing me when a socket becomes
> writable. I have seen this on both Linux and FreeBSD.

        I have no idea why it gave you a problem. Lots of people do this and 
you're
the first person to report a problem that I've ever seen.

> select() is very useful and an elegant solution for
> multiplexing sockets and doing non blocking IO.
> However it is useful only for getting to know when a
> socket becomes ready for read.

        Umm, no. It is just as useful to know what a socket is ready to write.

> I have seen code in which select() is used for getting
> to know pending writes. But this is only when we have
> written and for some reason the write operation does
> not write the full amount. In this case, we are
> interested when the socket becomes writeable bcoz we
> want to finish our write.

        That's one of the most common reasons why you would want to know if a
socket became writable. There are others. (There is no guarantee that your
very first call to 'write' for a single byte won't blockl)

> But if you naively check for write condition on a
> socke t with select() you will find that it always
> returns that the socket is writeable.

        No, it will not always return that the socket is writeable. It will 
return
that the socket is writeable if and only if the socket is in fact writeable.
This is precisely what it's *for*.

        Can you document a case where 'select' said that a socket was writeable
when it was not writeable?

> But I have always found non blocking IO to be a very
> advanced use of sockets and my advice will be that you
> should not attempt if you don't know what you are
> doing .

        I could not disagree more. Blocking I/O is much less forgiving because 
if
you accidentally call 'read' or 'write' at the wrong time, your program can
hang indefinitely. It is very hard to get blocking sockets right.

        DS


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to