This may be belated, but may serve as a good reference to future users. There is a good stream when using the select () function on the url http://developerweb.net/viewtopic.php?id=6824 . One example is given below:
int sslsock_handle_nbio (ssl, ret, totv) void *ssl; int ret; struct timeval *totv; { int sfd, i; fd_set rset, wset; sfd = SSL_get_fd (ssl); i = SSL_get_error (ssl, ret); if (i == SSL_ERROR_WANT_READ) { do { FD_ZERO (&rset); FD_SET (sfd, &rset); i = select (sfd + 1, &rset, NULL, NULL, totv); } while ((i < 0) && (errno == EINTR)); if (i == 0) { ret = -2; errno = ETIMEDOUT; } else { ret = i; } } else if (i == SSL_ERROR_WANT_WRITE) { do { FD_ZERO (&wset); FD_SET (sfd, &wset); i = select (sfd + 1, NULL, &wset, NULL, totv); } while ((i < 0) && (errno == EINTR)); if (i == 0) { ret = -2; errno = ETIMEDOUT; } else { ret = i; } } return (ret); }
This is only done after SSL_read()
or SSL_write()
.
source share