Hi, I have an application that does its network I/O using OpenSSL to make the code more portable, but which only optionally uses encryption. Now, I want my read/write calls to be nonblocking, i.e., to always return right away. I need to do this on Unix, which is what I'm familiar with, and on Windows, to which I'm new although I managed to build my client app using MinGW.
Here's a sketch (error handling snipped) of my OpenSSL code: /* If we use encryption, we have an SSL_CTX in ctx */ if (ctx) { bio = BIO_new_ssl_connect(ctx); BIO_set_conn_hostname(bio, hostname); BIO_do_connect(bio); BIO_do_handshake(bio); } else { /* no encryption case */ bio = BIO_new_connect(hostname); BIO_do_connect(bio); } Later I use BIO_read() and BIO_write() for the I/O. My questions now are: - Am I correct in assuming that SSL_read()/SSL_write() imply the use of encryption -- I can find more code examples using those but I want a transparent API regardless of whether encryption is used or not. - With a chain created using BIO_new_ssl_connect(), which fd is the critical one to set nonblocking (I presume it's just the one of the bio returned by BIO_new_ssl_connect() -- that's what I'm doing on Unix and it works). - On Windows, I've tried multiple ways of obtaining the socket/file descriptor of the bios involved, and then setting that nonblocking using ioctlsocket(), but no matter which bio I pick and how I call BIO_get_fd() I get an error that WSAGetLastError() says means "not a socket". Can someone please show me how to do this on Windows because I don't get it. - More precisely, if it's the file descriptor of the bio returned by BIO_new_ssl_connect() that I need to set nonblocking, how do I do that on Windows because that's an SSL BIO and thus doesn't use a socket underneath (right?) -- I don't even find a Windows API function to use for that. I've seen http://www.mail-archive.com/[EMAIL PROTECTED]/msg00540.html which was helpful but didn't solve it. As usual, sorry if this has been answered before -- I've done my googling and cannot find an answer for the entire context. Viega, Messier and Chandra say "these omitted functions can be implemented easily" on page 164, which reminds me of the way I shortcut my math proofs in Uni as "obvious" when I had no idea how to do them ;) Thanks a lot in advance! Christian. ps: no need to cc me, I'm subscribed. -- ________________________________________________________________________ http://www.cl.cam.ac.uk/~cpk25 http://www.whoop.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]