SSL_PENDING(3)

NAME
SSL_pending - obtain number of readable bytes buffered in an SSL object

SYNOPSIS
#include <openssl/ssl.h>
int
SSL_pending(const SSL *ssl);

DESCRIPTION
Data is received in whole blocks known as records from the peer. A whole record is processed, for example decrypted, in one go and is buffered until it is read by the application via a call to SSL_read(3).

SSL_pending() returns the number of bytes which are available inside ssl for immediate read.

SSL_pending() takes into account only bytes from the TLS/SSL record that is currently being processed (if any). If the ssl->read_ahead flag is set (see SSL_CTX_set_read_ahead(3)), additional protocol bytes beyond the current record may have been read containing more TLS/SSL records. This also applies to DTLS. These additional bytes will be buffered but will remain unprocessed until they are needed. As these bytes are still in an unprocessed state, SSL_pending() will ignore them. Therefore it is possible for no more bytes to be readable from the underlying BIO (because the library has already read them) and for SSL_pending() to return 0, even though readable application data bytes are available (because the data is in unprocessed buffered records).

RETURN VALUES
SSL_pending() returns the number of buffered and processed application data bytes that are pending and are available for immediate read.

SEE ALSO
ssl(3), SSL_CTX_set_read_ahead(3), SSL_read(3)

BUGS
Up to OpenSSL 0.9.6, SSL_pending() did not check if the record type of pending data is application data.