I think the openssl src already has sample server and client programs which are written in non blocking mode ..check wserver2.c if I am able to recall.
On Fri, May 6, 2011 at 2:42 PM, Graham Leggett <minf...@sharp.fm> wrote: > On 06 May 2011, at 9:23 PM, derleader mail wrote: > > Can you show us the source code. Paste it into pastebin.org. >> > > We do non blocking SSL by accepting the socket in the normal way (using > accept, not SSL_accept), and then wrapping the socket in a BIO like this: > > BIO *sbio = BIO_new_socket(c->socket, BIO_NOCLOSE); > SSL *ssl = SSL_new(ctx); > SSL_set_bio(ssl, sbio, sbio); > SSL_set_connect_state(ssl); > > We then put the socket in the event loop, and on read and write events we > called SSL_read and SSL_write as appropriate. The first time we call > SSL_read, the proper handshake is completed. > > One thing that you need to support for non blocking SSL to work properly is > to take account the fact that during SSL_write, SSL may want to read from > the socket, and during SSL_read, SSL may want to write. We keep track of > whether a "ready to read" event should call SSL_read or SSL_write as > appropriate, reacting to the SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE > result codes. > > Regards, > Graham > -- > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-users@openssl.org > Automated List Manager majord...@openssl.org >