That's what I figured, but then I came across the "WARNING" on the BIO_new_bio_pair page: http://www.openssl.org/docs/crypto/BIO_new_bio_pair.html
"As the data is buffered, SSL_operation() may return with a ERROR_SSL_WANT_READ condition, but there is still data in the write buffer. An application must not rely on the error value of SSL_operation() but must assure that the write buffer is always flushed first. Otherwise a deadlock may occur as the peer might be waiting for the data before being able to continue." That made me think that maybe the network BIO and internal BIO each have their own buffer, and I needed to flush the data between the network BIO and the internal BIO after doing a BIO_write to the network BIO. Thanks for the reply / clarification, n8 -----Original Message----- From: owner-openssl-us...@openssl.org [ Sent: Thursday, April 30, 2009 10:53 PM To: openssl-users@openssl.org Subject: Re: BIO_flush with BIO_pairs? On Thu, Apr 30, 2009 at 04:05:49PM -0700, Nate Leon wrote: > Is there any use for BIO_flush when using BIO_pairs? No, they don't have anywhere to drain (flush) the data to. BIO_pair ------------------ The <=> WSARecv <=> BIO_write <=> network | internal <=> SSL* <=> SSL_read Wire /Send /read BIO BIO /write > Is BIO_flush ever needed to move data between the network and internal BIO? > Such as: > BIO_write(networkBio, encryptedData, dwDataSize); > BIO_flush(networkBio); When you copy encrypted data from the network into the networkBio, it is already where it needs to be. There is no need to "flush it". This is not similar to a stdio buffer in-front of a kernel socket-pair. The buffers in the network BIO and internal BIO are more like kernel socket buffers than stdio buffers. Only a finite amount of data is stored in memory before further I/O must wait for the buffers to drain, but the buffered data is immediately available to be drained in either direction. -- Viktor.