--- "Dr. Stephen Henson" <[EMAIL PROTECTED]> wrote: > On Sat, Jul 22, 2006, Bu Bacoo wrote: > > > Thanks you both... after correcting my > BIO_do_connect (and all > > read/write following it) -> adding retries (as > Girish pointed), it > > works just fine. > > Now I'll check the errors, mentioned by Darryl, to > make it more clear, > > not just to retry until some counter runs out. > > > > By a strange coincidence I added some code to the > ocsp application a couple of > days ago that covers this situation. > > What you should do is call BIO_should_retry() if you > get <= 0 return from > BIO_do_connect() in fact until it connects you'll > get > BIO_should_retry_special() as true. > > You can loop until you get an error or > BIO_do_connect() succeeds but that > isn't very efficient and it non portable with the > current connect BIO > implementation on Windows as I found out when I > tried the updated ocsp > application with a timeout on WIN32. That should be > fixed I suppose. > > 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. 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. 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. 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. However a tight loop like while() is also inadvisable as it is very inefficient for BIO_do_connect(). Read the man page for SSL_read,read,write and SSL_write. It clearly gives you the particular error messages given by the socket for non blocking scenarios. EINPROGRESS and EAGAIN are errnos that come to mind. 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 . And as always be creative and try out various combos and let us know what works best. There was a related thread by Darryl few weeks ago. Check in the archives. That will throw some light on how difficult this becomes. All the best! regards, Girish > > 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 > openssl-users@openssl.org > Automated List Manager > [EMAIL PROTECTED] > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]