Title: Confusion about SSL_ERROR_WANT_READ/WRITE

I have an app where reads and writes happen from different threads.  Now, ideally, one would envision that I just replace the reads/writes with SSL_read/SSL_write.  Now I know it is not as simple as that.

What exactly is the meaning of the SSL_ERROR_WANT_READ/WRITE errors?

If I get I get a WANT_READ from an SSL_read, I guess that means I need to read more data but no data is available on the socket yet.  So I basically poll/select waiting for more data to arrive before I can reissue the SSL_read.  Is that right? 

If I get a WANT_WRITE from an SSL_read, does that mean that I need to do an SSL_write before I can reissue the SSL_read?  And if so, what if I have no data to write?  Can I just do an SSL_write() with an empty buffer?  I'm assuming it is not application data that needs to be written, but some data contained in some internal ssl buffer?

If I get a WANT_WRITE from an SSL_write, does that mean the network buffer is full and I cannot write to the socket yet?  In which case, I would just poll/select until the socket becomes writable and retry the SSL_write?

What if I get a WANT_READ from an SSL_write?  Does that mean that I need to do an SSL_read before I can reissue the SSL_write?  Again, I'm assuming the data that needs to be read is not application data. So can I just do an SSL_read giving it a 0 length buffer?  Will this cause whatever data that is stored in the ssl buffers to be processed without reading data off the network (since I have a separate thread for reading and processing application data)?

Ed

Reply via email to