> To make it clearer. Select or poll will return as soon as the socket is > writable. However, SSL still needs to negotiate keys and > encryption with the > peer before you can exchange any data. This is handled > transparently for you > in each SSL_write call. Therefore SSL replies to you "Yes the socket is > writeable, but I am not done yet with the handshake".
That would be SSL_ERROR_WANT_READ. If you get SSL_ERROR_WANT_WRITE, that means OpenSSL found that the socket was not wriable. > When you get SSL_ERROR_WANT_WRITE none of your data is written to the > socket. There is no such guarantee. OpenSSL may have written some, all, or none of your data to the socket. All that you know is: 1) OpenSSL needs the socket to be writable to make further progress in this direction. 2) You must provide the same data to OpenSSL the next time you call SSL_write. However, it is entirely legal within the specification for all the data to appear on the other end of the connection. (Though in practice, this won't happen.) > You need to put it in a loop and call select or poll > again. If you > want to be efficient and not do many loops, put a sched_yield(); > inside your > loop. That would be pointless. The 'select' or 'poll' function permits efficient blocking and beneficial context switches. Adding a sched_yield only adds context switches where they are not necessary and blows out the caches. DS ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [email protected] Automated List Manager [email protected]
