Topic: wolfSSL_read blocking?

I am polling(poll/select) a blocking OS socket for readability, and was wondering that if i get signaled readability from the OS if i can also be  sure that wolfSSL_read() will not block.

I am mainly concerned that if for example a protocol message or only half a ssl record arrived that wolfSSL_read() would block, can you tell me if it would block or not and how the general way to go about this would be (just set nonblocking and still poll the underlying socket?) with wolfSSL.

Share

Re: wolfSSL_read blocking?

Hi,

wolfSSL embedded SSL is agnostic towards blocking.  It doesn't even assume sockets are being used; it could be a memory buffer, a file, or something else entirely.  It uses an I/O abstraction layer to ask for data.  If you are using sockets and you want to ensure that SSL_read() doesn't block make sure the underlying file descriptor is set to non blocking.  If the underlying fd returns EWOULDBLOCK or EAGAIN then wolfSSL_read() will return SSL_FAILURE and wolfSSL_get_error() will return SSL_ERROR_WANT_READ.

Hope that helps,
-Todd

Share