On Sat, Jul 22, 2006, Girish Venkatachalam wrote: > --- "Dr. Stephen Henson" <[EMAIL PROTECTED]> wrote: > > > > > > > The efficient thing to do depends on the underlying > > transport. > > Getting the actual socket description with > > BIO_get_fd() then calling select() > > while waiting for a write condition is often done > > for example. > > 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. >
Yes but this is a special case. It isn't really checking to see if the socket becomes writeable at all. If you check the manual page for connect() on many Un*x variants it will say that if it is called on a non blocking socket and indicates an operation would block (EAGAIN, EWOULDBLOCK error codes for example) then it is possible to wait on that socket for a write condition which will be satisfied when a connection is established. It isn't really a write condition in this case it is a "wait until the socket connects" condition. OpenSSL BIO logic doesn't indicate this condition with BIO_should_write() instead it uses BIO_should_io_special(). This is to cover the case where some TCP/IP transport implementation might want to wait for a special condition instead of using writeable for this purpose. The WIN32 manual pages are slightly different in that they don't recommend calling connect() in a loop until it completes because different error codes can occur other than WSAEWOULDBLOCK after the first call. This means that looping BIO_do_connect() on a non blocking socket will not currently work in WIN32, we should really change the state machine to cover this. Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Funding needed! Details on homepage. Homepage: http://www.drh-consultancy.demon.co.uk ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [email protected] Automated List Manager [EMAIL PROTECTED]
