---
name: "libressl-SSL_CTX_set_read_ahead"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-SSL_CTX_set_read_ahead"
---

# libressl-SSL\_CTX\_set\_read\_ahead(3)

manage whether to read as many input bytes as possible

## NAME

**SSL\_CTX\_set\_read\_ahead**, **SSL\_CTX\_get\_read\_ahead**, **SSL\_set\_read\_ahead**, **SSL\_get\_read\_ahead**, **SSL\_CTX\_get\_default\_read\_ahead** – manage whether to read as many input bytes as possible

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

**#include \<openssl/ssl.h\>**

*void*\

**SSL\_CTX\_set\_read\_ahead**(*SSL\_CTX \*ctx*, *int yes*);

*long*\

**SSL\_CTX\_get\_read\_ahead**(*SSL\_CTX \*ctx*);

*void*\

**SSL\_set\_read\_ahead**(*SSL \*s*, *int yes*);

*long*\

**SSL\_get\_read\_ahead**(*const SSL \*s*);

*long*\

**SSL\_CTX\_get\_default\_read\_ahead**(*SSL\_CTX \*ctx*);

## DESCRIPTION

**SSL\_CTX\_set\_read\_ahead**() and **SSL\_set\_read\_ahead**() set whether as many input bytes as possible are read for non-blocking reads. For example if *x* bytes are currently required by OpenSSL, but *y* bytes are available from the underlying BIO (where *y* \> *x*), then OpenSSL will read all *y* bytes into its buffer (provided that the buffer is large enough) if reading ahead is on, or *x* bytes otherwise. The parameter *yes* should be 0 to ensure reading ahead is off, or non zero otherwise.

**SSL\_CTX\_get\_read\_ahead**() and **SSL\_get\_read\_ahead**() indicate whether reading ahead is set or not.

**SSL\_CTX\_get\_default\_read\_ahead**() is identical to **SSL\_CTX\_get\_read\_ahead**().

These functions are implemented as macros.

These functions have no effect when used with DTLS.

## RETURN VALUES

**SSL\_CTX\_get\_read\_ahead**() and **SSL\_get\_read\_ahead**() return 0 if reading ahead is off or non-zero otherwise, except that the return values are undefined for DTLS.

## SEE ALSO

[ssl(3)](/ssl/3.md), SSL\_pending(3)

## HISTORY

**SSL\_set\_read\_ahead**() and **SSL\_get\_read\_ahead**() appeared in SSLeay 0.4 or earlier and have been available since OpenBSD 2.4.

**SSL\_CTX\_set\_read\_ahead**(), **SSL\_CTX\_get\_read\_ahead**(), and **SSL\_CTX\_get\_default\_read\_ahead**() first appeared in OpenSSL 0.9.2b and have been available since OpenBSD 2.6.

## CAVEATS

Switching read ahead on can impact the behaviour of the SSL\_pending(3) function.
