---------------------------- Original Message ----------------------------
Subject: RE:I am having a hard time getting SSL_Accept to work with a     
non     blocking socket From:    "Gayathri Sundar" <[EMAIL PROTECTED]>
Date:    Sun, June 5, 2005 11:33 pm
To:      openssl-users@openssl.org
--------------------------------------------------------------------------

Hi,

while (((rc = SSL_accept(ssl)) <= 0) &&
          ((SSL_get_error(ssl, rc) == SSL_ERROR_WANT_READ) ||
           (SSL_get_error(ssl, rc) == SSL_ERROR_WANT_WRITE)))
       {
          /* as on wait application can do something else */
          do_other_stuff();
        }

hope you have called
SSLBio = BIO_new_socket(ulFd, BIO_NOCLOSE);
* Sets the BIO associated with Socket FD to Non Blocking Mode */
BIO_socket_ioctl(ulFd,FIONBIO,&Switch)
SSL_set_bio(SSLObj,SSLBio,SSLBio)


int ssl_accept()
{
  /* Do the handshake */
  iRetVal = SSL_accept(SSLObj);
  if(iRetVal == 1)
  {
    return 1;
  }
  else
  {
     iRetVal = SSL_get_error(SSLObj, iRetVal);
     switch(iRetVal)
     {
        case SSL_WANT_READ:
        case SSL_WANT_ACCEPT:
          /* This means that the SSL_accept is blocked and should be
            retried when the fd is available for reading. So, add to the
             poll table to look for READ event */
             /* application should poll for READ */
             return(SSL_WANT_READ);
        case SSL_WANT_WRITE:
        case SSL_WANT_CONNECT:
          /* This means that the SSL_accept is blocked and should be
             retried when the fd is available for writing. So, add to the
poll table to look for WRITE event */
             /* application should poll for WRITE */
             return(SSL_WANT_WRITE);
        default:
             /* Abort the accept as its a permanent error */
            return 0;
     }
  }
}


===========================================================================
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                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]




______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to