BIO_CTRL(3SSL)
π BIO_CTRL(3SSL) β the OpenSSL one, bestie π
okay so this is the OpenSSL girlies' page for all the BIO control operations, and honestly it's a whole vibe. it's filed under BIO_CTRL(3SSL) and it's giving "I hold the entire I/O stack together and I still look cute doing it." β¨
π NAME π
BIO_ctrl, BIO_callback_ctrl, BIO_ptr_ctrl, BIO_int_ctrl, BIO_reset, BIO_seek, BIO_tell, BIO_flush, BIO_eof, BIO_set_close, BIO_get_close, BIO_pending, BIO_wpending, BIO_ctrl_pending, BIO_ctrl_wpending, BIO_get_info_callback, BIO_set_info_callback, BIO_info_cb, BIO_get_ktls_send, BIO_get_ktls_recv, BIO_set_conn_mode, BIO_get_conn_mode, BIO_set_tfo β all of them, together, doing BIO control operations. periodt. π
π¦ SYNOPSIS π¦
no cap, here's the whole cast list:
#include <openssl/bio.h>
typedef int BIO_info_cb(BIO *b, int state, int res);
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *cb);
void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
int BIO_reset(BIO *b);
int BIO_seek(BIO *b, int ofs);
int BIO_tell(BIO *b);
int BIO_flush(BIO *b);
int BIO_eof(BIO *b);
int BIO_set_close(BIO *b, long flag);
int BIO_get_close(BIO *b);
int BIO_pending(BIO *b);
int BIO_wpending(BIO *b);
size_t BIO_ctrl_pending(BIO *b);
size_t BIO_ctrl_wpending(BIO *b);
int BIO_get_info_callback(BIO *b, BIO_info_cb **cbp);
int BIO_set_info_callback(BIO *b, BIO_info_cb *cb);
int BIO_get_ktls_send(BIO *b);
int BIO_get_ktls_recv(BIO *b);
int BIO_set_conn_mode(BIO *b, int mode);
int BIO_get_conn_mode(BIO *b);
int BIO_set_tfo(BIO *b, int onoff);
πΈ DESCRIPTION πΈ
BIO_ctrl(), BIO_callback_ctrl(), BIO_ptr_ctrl() and BIO_int_ctrl() are the BIO "control" operations, and they take arguments of various types because why be boring. tbh you don't normally call these directly β various macros get used instead. The standard macros are described below, and the macros specific to a particular type of BIO get described in that specific BIO's manual page, plus any special features of the standard calls. iykyk. π«Ά
BIO_reset() typically resets a BIO to some initial state β in the case of file related BIOs, for example, it rewinds the file pointer to the start of the file. iconic behavior honestly.
BIO_seek() resets a file related BIO's (that is file descriptor and FILE BIOs) file position pointer to ofs bytes from start of file. π―
BIO_tell() returns the current file position of a file related BIO.
BIO_flush() normally writes out any internally buffered data. in some cases it's used to signal EOF and that no more data will be written. it's giving "last call at the function." π
BIO_eof() returns 1 if the BIO has reached end-of-file as a result of the most recent read operation. The precise meaning of "EOF" varies according to the BIO type. And listen β the function reports the result of the previous read attempt and does not update this state based on subsequent operations. so don't come for it. π
BIO_set_close() sets the BIO b close flag to flag. flag can take the value BIO_CLOSE or BIO_NOCLOSE. Typically BIO_CLOSE is used in a source/sink BIO to indicate that the underlying I/O stream should be closed when the BIO is freed. β¨
BIO_get_close() returns the BIOs close flag.
BIO_pending(), BIO_ctrl_pending(), BIO_wpending() and BIO_ctrl_wpending() return the number of pending characters in the BIOs read and write buffers. not all BIOs support these calls bestie, be warned. BIO_ctrl_pending() and BIO_ctrl_wpending() return a size_t type and are functions, while BIO_pending() and BIO_wpending() are macros which call BIO_ctrl(). two icons, two delivery mechanisms. π
BIO_get_ktls_send() returns 1 if the BIO is using the Kernel TLS data-path for sending. Otherwise, it returns zero. BIO_get_ktls_recv() returns 1 if the BIO is using the Kernel TLS data-path for receiving. Otherwise, it returns zero. β¨
BIO_get_conn_mode() returns the BIO connection mode. BIO_set_conn_mode() sets the BIO connection mode. main character energy fr fr. π
BIO_set_tfo() disables TCP Fast Open when onoff is 0, and enables TCP Fast Open when onoff is nonzero. Setting the value to 1 is equivalent to setting BIO_SOCK_TFO in BIO_set_conn_mode(). π₯
β RETURN VALUES β
ugh okay here's the receipts, and some of them are ambiguous so pay attention:
BIO_reset()normally returns1for success and<=0for failure. File BIOs are an exception β they return0for success and-1for failure. (yes really. the audacity.) πBIO_seek()andBIO_tell()both return the current file position on success and-1for failure, except file BIOs which forBIO_seek()always return0for success and-1for failure.BIO_flush()returns1for success and<=0for failure.BIO_eof()returns1if EOF has been reached,0if not, or negative values for failure.BIO_set_close()returns1on success or<=0for failure.BIO_get_close()returns the close flag value:BIO_CLOSEorBIO_NOCLOSE. It also returns other negative values if an error occurs.BIO_pending(),BIO_ctrl_pending(),BIO_wpending()andBIO_ctrl_wpending()return the amount of pending data.BIO_pending()andBIO_wpending()return negative value or0on error.BIO_ctrl_pending()andBIO_ctrl_wpending()return0on error.BIO_get_ktls_send()returns1if the BIO is using the Kernel TLS data-path for sending. Otherwise, it returns zero.BIO_get_ktls_recv()returns1if the BIO is using the Kernel TLS data-path for receiving. Otherwise, it returns zero.BIO_set_conn_mode()returns1for success and0for failure.BIO_get_conn_mode()returns the current connection mode. Which may contain the bitwise-or of the following flags:
BIO_SOCK_REUSEADDR
BIO_SOCK_V6_ONLY
BIO_SOCK_KEEPALIVE
BIO_SOCK_NONBLOCK
BIO_SOCK_NODELAY
BIO_SOCK_TFO
BIO_set_tfo()returns1for success, and0for failure.
π NOTES π
BIO_flush(), because it can write data, may return 0 or -1 indicating that the call should be retried later in a similar manner to BIO_write_ex(). The BIO_should_retry() call should be used and appropriate action taken is the call fails. so bestie, always check before you assume it ate. π
The return values of BIO_pending() and BIO_wpending() may not reliably determine the amount of pending data in all cases. For example in the case of a file BIO some data may be available in the FILE structures internal buffers but it is not possible to determine this in a portably way. For other types of BIO they may not be supported. it's giving "trust me bro" and honestly, no. π
Filter BIOs β if they do not internally handle a particular BIO_ctrl() operation β usually pass the operation to the next BIO in the chain. This often means there is no need to locate the required BIO for a particular operation, because you can call it on a chain and it will be automatically passed to the relevant BIO. however, this can cause unexpected results: for example no current filter BIOs implement BIO_seek(), but this may still succeed if the chain ends in a FILE or file descriptor BIO. the relay race is real. πβοΈ
Source/sink BIOs return an 0 if they do not recognize the BIO_ctrl() operation.
π BUGS π
Some of the return values are ambiguous and care should be taken. In particular a return value of 0 can be returned if an operation is not supported, if an error occurred, if EOF has not been reached and in the case of BIO_seek() on a file BIO for a successful operation. yes bestie, 0 means like four different things. we don't make the rules. π
In older versions of OpenSSL the BIO_ctrl_pending() and BIO_ctrl_wpending() could return values greater than INT_MAX on error.
π HISTORY π
The BIO_get_ktls_send() and BIO_get_ktls_recv() macros were added in OpenSSL 3.0. They were modified to never return -1 in OpenSSL 3.0.4. glow-up era. β¨
The BIO_get_conn_mode(), BIO_set_conn_mode() and BIO_set_tfo() functions were added in OpenSSL 3.2. new girls on the block. π
π COPYRIGHT π
Copyright 2000-2026 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the tea, bestie π«Ά this whole page is from OpenSSL version 4.0.3, dated 2026-09-29, and it lives under the name BIO_CTRL(3SSL). go forth and control your BIOs. slay. π πΈπ¦
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms