Hello,

I am using a non-blocking socket to connect to a server. I have the
following code which works fine. The issue is that the while loop
executes almost 3000 times! Is this expected? When I am waiting for
select/epoll to return, I was expecting it to return only when the
connection completes, much like blocking connect(). Is there a better
way of writing the code?

Thanks, Rij

        ssl = SSL_new(ctx);
        sbio = BIO_new_socket(sock, BIO_NOCLOSE);
        SSL_set_bio(ssl, sbio, sbio);
        connected = 0;
        while (1)
        {
                r_code = SSL_connect(ssl);
                if (r_code == 1)
                        break;

                switch(SSL_get_error(ssl, r_code))
                {
                        case SSL_ERROR_WANT_WRITE:
                        case SSL_ERROR_WANT_READ:               
                                /* Wait for epoll/select to return */           
                
                                break;
                }
        }
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [email protected]

Reply via email to