BIO_S_SOCKET(3SSL)
π BIO_S_SOCKET π
okay bestie, welcome to the socket BIO page β that's BIO_S_SOCKET(3SSL) from the OpenSSL manual, and yes we're doing this together, hand in hand, no cap π«Ά
β¨ NAME β¨
BIO_s_socket, BIO_new_socket, BIO_set_send_flags β it's giving socket BIO energy, fr fr π¦
πΈ SYNOPSIS πΈ
#include <openssl/bio.h>
const BIO_METHOD *BIO_s_socket(void);
BIO *BIO_new_socket(int sock, int close_flag);
long BIO_set_send_flags(BIO *b, int flags);
look at those three little lines, so compact, so iconic π
π DESCRIPTION π
BIO_s_socket()β returns the socket BIO method. Think of it as a cute lil wrapper round your platform's socket routines. she's not doing the work herself, she's delegating πβοΈBIO_read_ex()andBIO_write_ex()β these two read or write the underlying socket. the main characters, honestly.BIO_puts()is supported β¨ butBIO_gets()is not. and we simply don't talk about it π (jk we do, it's listed right there, just don't expectBIO_gets()to work on a socket BIO).- If the close flag is set, then the socket gets shut down and closed when the BIO is freed. so like, she leaves the party and turns off the lights on her way out π₯
BIO_new_socket()β returns a socket BIO usingsockandclose_flag. that's it, that's the whole job. slay.BIO_set_send_flags()β setsflagspassed tosend(),sendto()andsendmsg(). The set of available flags is platform-dependent, so pls don't assume, bestie. The main intention here is to allow setting theMSG_NOSIGNALflag to avoid a crash on receiving theSIGPIPEsignal. yes really, that's the whole reason she exists β she's a bodyguard for your process π€π
π NOTES π
Socket BIOs also support any relevant functionality of file descriptor BIOs. they're flexible like that, versatile queen π
So why do file descriptor BIOs and socket BIOs even exist separately?? the tea β: on some platforms, sockets are not file descriptors and use distinct I/O routines. Windows is one such platform, iykyk. Any code mixing the two will not work on all platforms. periodt. don't do it. π«
π¦ RETURN VALUES π¦
BIO_s_socket()β returns the socket BIO method. every time, no drama.BIO_new_socket()β returns the newly allocated BIO, orNULLif an error occurred. so if you seeNULL... yeah. that happened. πBIO_set_send_flags()β returns1on success,0on errors. simple binary, we love to see it.
β HISTORY β
BIO_set_send_flags() was added in OpenSSL 4.0. she's new here, be nice to her, she's already thriving π
π 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 whole page bestie, you ate that π β¨ this was OpenSSL 4.0.3, dated 2026-09-29 β mwah, go write some sockets, ily π«Άπ
π¦ 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