NNG_SOCKET_PAIR(3supp)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… NNG_SOCKET_PAIR (3supp) β€” from the NNG Reference Manual, bestie ✨

🌸 NAME 🌸

nng_socket_pair β€” the glow-up that makes you a connected pair of BSD sockets πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <nng/nng.h>

int nng_socket_pair(int fds[2]);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: nng_socket_pair() literally creates a pair of connected BSD sockets for you, no cap. They come back to you in the fds array, and β€” this is the important part β€” they're suitable for use with the socket transport. slay πŸ’…

On POSIX platforms this is just a thin wrapper around the standard socketpair() function, using the AF_UNIX family and the SOCK_STREAM socket type. iconic behavior honestly 🫢

πŸ“Œ Note: rn, only POSIX platforms that implement socketpair() are supported with this function. so like… vibe check your platform first, okay? 😭
πŸ’‘ Tip: this function is lowkey perfect for creating a shared connection between a parent process and a child process on UNIX platforms β€” and the way that it does it without requiring a shared filesystem or a TCP connection?? obsessed. πŸ”₯

⭐ RETURN VALUES ⭐

This function returns 0 on success, and non-zero otherwise. that's it, that's the whole vibe ✨


πŸ’€ ERRORS πŸ’€

  • NNG_ENOMEM β€” insufficient memory exists. not enough room bestie, it's giving full closet 😭
  • NNG_ENOTSUP β€” this platform does not support socket pairs. rude of it, honestly πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘


go read those, iykyk πŸ’œ

mwah, that's the page β€” brought to you by the NNG Reference Manual, dated 2026-01-13, and yes the footer still says NNG_SOCKET_PAIR(3supp) bc we keep it accurate around here πŸŽ€βœ¨

πŸ“¦ where this page comes from