I am confused about the difference between the BIO routines BIO_read()/BIO_write() and the SSL_read()/SSL_write() when the BIOs are memory BIOs and not socket BIOs.
I am trying to code a WebRTC server using libnice for the ICE stack and openssl for the DTLS stack. The ICE stack has the socket connection to the client so I cannot use the socket-based BIOs in openssl. Instead, I am using the memory BIOs.
So the high level procedure I am using is that, when I receive the DTLS messages from the client on the ICE socket, I write that message to the DTLS stack using BIO_write(). Then when the DTLS stack has a message to send to the client I get that message using the BIO_read() and send it to the client using the ICE socket.
I have seen some examples of source code that does essentially this procedure, but they also call the SSL_read() routine after the BIO_write() call. This makes no sense to me. Why is the call to SSL_read() necessary after I essentially have written the client message into the DTLS stack using the BIO_write() call? If I do not call SSL_read() after the BIO_write() my code does not work. But when I call SSL_read() after the BIO_write(), this is indeed exchanging the handshake messages with the browser client.
Question: using memory BIOs, what is the difference between BIO_read() and SSL_read(); Question: using memory BIOs, what is the difference between BIO_write() and SSL_write()? Question: is the default memory BIO blocking or nonblocking? I am assuming it is nonblocking since it is a memory-base BIO and not a socket-base BIO.
Thanks, -Andres