io_socketpair(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– io_socketpair β€” create a pair of sockets πŸ’–

okay bestie, so this is io_socketpair from the <libowfat/io.h> era of your life (page 3 of the Library Functions Manual, she's fancy) and she is here to hand you two sockets that are already besties with each other. no cap.


✨ SYNTAX ✨

#include <libowfat/io.h>

int io_socketpair(int64 pfd[2]);

🌸 DESCRIPTION 🌸

okay so here's the tea: io_socketpair creates a brand new UNIX socket pair and writes both descriptors to d. that's it, that's the job. πŸ’…

and the way this socket pair works?? it's giving pipe energy, but make it bidirectional β€” meaning both descriptors are for reading and writing. so they can talk back and forth, mutual, no one-sided situationships here. it's giving healthy communication for once 😭🫢

now for the important part, the vibe check on return values:

  • io_socketpair returns 1 to indicate success ✨ iconic, ate, no notes.
  • if something goes wrong, it returns 0 and sets errno to indicate the error πŸ˜” in that case it frees any memory that it allocated for the new socketpair, and it leaves d alone. like, it cleans up after itself and does NOT touch your stuff. respectful king behavior honestly.
lowkey crucial: 0 means failure and errno has the lore. don't be out here ignoring that, bestie.

πŸ‘€ SEE ALSO πŸ‘€

the girlies you should also be reading:


k that's the whole page, you're literally a socket pair expert now πŸŽ€ stay hydrated, close your file descriptors, and remember β€” this was io_socketpair(3) from the Library Functions Manual, mwah πŸ’‹πŸ’–βœ¨πŸ¦‹