NNG_SOCKET(7)

πŸ“¦
version 1.12.0 Β· 4 versions
, in ubuntu stonking

πŸ’– NNG_SOCKET πŸ’–

okay bestie, grab your strawberry matcha πŸ“ because today we're learning about nng_socket, the BSD Socket transport from the NNG Reference Manual. she's experimental, she's mysterious, she's giving ✨main character✨. let's get into it.


🌸 NAME 🌸

nng_socket β€” BSD Socket transport (experimental)


πŸ¦‹ DESCRIPTION πŸ¦‹

so the socket transport lets peers talk to each other across any BSD socket you throw at it β€” like, literally any of them, the ones you make with nng_socket_pair() included. it's flexible like that, slay πŸ’….

here's the big plot twist though: this transport only supports listeners, created with nng_listener_create().

⚠️ bestie listen β€” if you try to make a dialer with this transport, you get NNG_ENOTSUP. it's just not that kind of girl. no dialers. periodt.

the socket file descriptor gets handed to the listener using the NNG_OPT_SOCKET_FD option (as an integer). set that option and the listener will create a pipe β€” backed by the file descriptor you passed in. iconic behavior, no cap 🫢.

about the protocol between peers: it's compatible with the protocol used for the TCP transport, BUT β€” and this is important β€” that's an implementation detail and it's subject to change without notice. so don't build your whole personality around it. 😭

πŸ’€ also: this transport is experimental, and at present it's only supported on POSIX platforms. that's the vibe check, and the vibe says POSIX only.

πŸŽ€ Registration πŸŽ€

good news, zero effort required β€” no special action is necessary to register this transport. she just shows up. love that for us. πŸ’–


🌈 URI Format 🌈

this transport uses the URL socket://, without further qualification. clean, simple, no extra drama. ✨


🧚 Socket Address 🧚

the socket address will be of family NNG_AF_UNSPEC. and that's it β€” there are no further socket details available. mysterious queen. πŸ‘‘


πŸ’… Transport Options πŸ’…

the following transport option is available:

  • NNG_OPT_SOCKET_FD β€” (int) this one is a write-only option, and it may be set multiple times on a listener. every single time you set it, the listener creates a pipe backed by the given file descriptor you passed as an argument. so yes, you can stack her up. πŸ”₯

additionally, the following options may be supported on pipes when the platform supports them:

  • NNG_OPT_PEER_GID
  • NNG_OPT_PEER_PID
  • NNG_OPT_PEER_UID
  • NNG_OPT_PEER_ZONEID

(no promises on those last four β€” it's platform dependent, so check your platform before you get your hopes up πŸ™ˆ)


🫢 SEE ALSO 🫢


and that's the whole page bestie, you ate it up πŸ’– this version is dated 2026-06-30, part of the NNG Reference Manual, and it's NNG_SOCKET(7) β€” so go forth, make those listeners, and remember: no dialers, POSIX only, and the TCP-protocol compatibility is a secret she tells nobody. iykyk. byeee πŸŒΈπŸ¦‹πŸ’œ

πŸ“¦ where this page comes from