Reputation: 11
I am quite a new at using openssl, and i'm attempting to accept a nonblocking connection from a blocking server, i've read a couple questions asking exactly this question found here: Non-blocking connect OpenSSL SSL CONNECT produces -1 ERROR
most of the answers say to recall the SSL_accept() function again, how would I go about doing this? would I just do a while (true) loop until the client calls the connection?
here's the current code for accepting the connection
int code = SSL_accept(ssl);
if (code <= 0)
{
int ssl_error = SSL_get_error(ssl, code);
if (ssl_error == SSL_ERROR_WANT_READ || ssl_error == SSL_ERROR_WANT_WRITE)
{
//ignore
}
else if (ssl_error == SSL_ERROR_ZERO_RETURN)
{
//remove connection
}
else
{
cout << code << endl; //returns -1
cout << ssl_error << endl; //returns 1 (SSL_ERROR_SSL)
//remove connection (the code usually leads to here)
}
}
Upvotes: 1
Views: 77