I am having a hard time getting SSL_Accept to work with a non blocking socket

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

I am having a hard time getting SSL_Accept to work with a non blocking socket

Eric Gold
Hi there, I am pulling my hair out trying to get SSL_accept to work with
a non blocking socket. When I make a call to SSL_accept and then perform
an SSL_get_error. I get the error SSL_ERROR_WANT_READ. At this point
what should I do. Currently I am doing the following:

 while (((rc = SSL_accept(ssl)) <= 0) &&
          ((SSL_get_error(ssl, rc) == SSL_ERROR_WANT_READ) ||
           (SSL_get_error(ssl, rc) == SSL_ERROR_WANT_WRITE)))
       {}

but I never get out of this loop.

I am also using select to obtain read events for this socket. In the
case mentioned above do I need to check select for a read event prior to
calling retrying SSL_accept.


HELP MUCH APPRECIATED!
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: I am having a hard time getting SSL_Accept to work with a nonblocking socket

Bernhard Fröhlich-2
Eric Gold wrote:

>Hi there, I am pulling my hair out trying to get SSL_accept to work with
>a non blocking socket. When I make a call to SSL_accept and then perform
>an SSL_get_error. I get the error SSL_ERROR_WANT_READ. At this point
>what should I do. Currently I am doing the following:
>
> while (((rc = SSL_accept(ssl)) <= 0) &&
>          ((SSL_get_error(ssl, rc) == SSL_ERROR_WANT_READ) ||
>           (SSL_get_error(ssl, rc) == SSL_ERROR_WANT_WRITE)))
>       {}
>
>but I never get out of this loop.
>
>I am also using select to obtain read events for this socket. In the
>case mentioned above do I need to check select for a read event prior to
>calling retrying SSL_accept.
>
>
>HELP MUCH APPRECIATED!
>  
>
Have you already had a look at
http://www.openssl.org/docs/ssl/SSL_accept.html?
Is the socket already connected? What kind of BIO are you using?

Just want to gain time to make some tests myself... ;)
Ted
;)

smime.p7s (4K) Download Attachment