BIO_S_SOCKET(3)
π BIO_S_SOCKET(3) β the socket BIO page, bestie edition
okay so this is BIO_S_SOCKET(3) from the Library Functions Manual, living over in libcrypto land. buckle up, we're talking sockets πΈ
β¨ NAME β¨
BIO_s_socket, BIO_new_socket β the socket BIO, no cap π«Ά
β¨ SYNOPSIS β¨
library βlibcryptoβ #include <openssl/bio.h>
const BIO_METHOD *
BIO_s_socket(void);
BIO *
BIO_new_socket(int sock, int close_flag);
β¨ DESCRIPTION β¨
so BIO_s_socket() returns the socket BIO method π« literally it's a wrapper around the platform's socket routines. that's the whole vibe.
BIO_read(3) and BIO_write(3) read or write the underlying socket. BIO_puts(3) is supported but BIO_gets(3) is not. not me telling you BIO_gets is not invited to the party π
if the close flag is set, then the socket is shut down and closed when the BIO is freed. clean exit, iconic behavior π
BIO_new_socket() returns a socket BIO using sock and close_flag.
socket BIOs also support any relevant functionality of file descriptor BIOs. it's giving "we share a closet" π
and now the part that's actually important, so listen up bestie π β the reason for having separate file descriptor and socket BIOs is that on some platforms, sockets are not file descriptors and use distinct I/O routines. Windows is one such platform. any code mixing the two will not work on all platforms. so like... don't do that π
lowkey a real warning: mix file descriptor BIOs and socket BIOs at your own risk, because on platforms where sockets aren't file descriptors it will absolutely fall apart. fr fr π
β¨ RETURN VALUES β¨
BIO_s_socket()returns the socket BIO method β¨BIO_new_socket()returns the newly allocated BIO orNULLif an error occurred π- when called on a socket BIO object,
BIO_method_type(3)returns the constantBIO_TYPE_SOCKETandBIO_method_name(3)returns a pointer to the static string"socket"π
β¨ SEE ALSO β¨
BIO_get_fd(3), BIO_new(3) β go read those next, bestie, iykyk π¦
β¨ HISTORY β¨
BIO_s_socket() first appeared in SSLeay 0.6.0. BIO_new_socket() first appeared in SSLeay 0.8.0. both functions have been available since OpenBSD 2.4. we love a long-running icon β
and that's the whole page, bestie β Debian, dated June 8, 2025, BIO_S_SOCKET(3), slay ππ§ββοΈ
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms