BIO_S_SOCKET(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… BIO_S_SOCKET β€” OpenSSL Manual, but make it make sense

okay so bestie, this is the BIO_S_SOCKET(3ossl) page from the OpenSSL fam β€” yes, that OpenSSL, the one your whole internet depends on. sit down, grab a lil snack πŸ“, and let's talk about the socket BIO, which is literally just a glow-up wrapper around your platform's socket routines. no cap.


🌸 NAME 🌸

BIO_s_socket, BIO_new_socket β€” the socket BIO, aka the moment your SSL code gets to actually talk to a real live socket. iconic behaviour tbh πŸ’…


✨ SYNOPSIS ✨

#include <openssl/bio.h>

const BIO_METHOD *BIO_s_socket(void);

BIO *BIO_new_socket(int sock, int close_flag);

like, that's it. two functions. short king energy πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

So BIO_s_socket() hands you back the socket BIO method β€” think of it as the main character BIO method that wraps round the platform's socket routines. it's giving "I'm just a thin layer but I'm doing the most" πŸ¦‹

Then for actually moving bytes:

  • BIO_read_ex() and BIO_write_ex() read or write the underlying socket. that's the whole job fr fr.
  • BIO_puts() is supported πŸŽ€
  • BIO_gets() is not supported πŸ™ˆ so don't come for her, she simply doesn't do that

And the close flag? listen: if close_flag is set, then the socket gets shut down and closed when the BIO is freed. so like, when you're done, she's done done. ✨

BIO_new_socket() returns a socket BIO using sock and close_flag. that's your constructor, that's your moment, go off πŸ’œ


🫢 NOTES 🫢

Socket BIOs also support any relevant functionality of file descriptor BIOs β€” so they're not total strangers, they do share the vibe.

But bestie, why do file descriptor BIOs and socket BIOs even exist separately?? πŸ‘€ Because on some platforms sockets are not file descriptors and they use distinct I/O routines. Windows is literally one of those platforms, and Windows is always one of those platforms 😭

⚠️ Real talk: any code that mixes the two will not work on all platforms. not "might not", will not. so don't do it. no cap. πŸ’€

πŸ”₯ RETURN VALUES πŸ”₯

  • BIO_s_socket() returns the socket BIO method. always, no drama. βœ…
  • BIO_new_socket() returns the newly allocated BIO β€” OR NULL if an error occurred. so like, check for the NULL, bestie, please, I'm begging πŸ™ 😭

Copyright 2000-2016 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 πŸ§šπŸ’– that was 3.5.0, dated 2026-09-25, straight from the OpenSSL brain trust β€” <rainbow>slay, stay socketed, and may your NULLs never sneak up on you</rainbow> 🌈⭐

πŸ“¦ where this page comes from