NNG_SOCKET(7)
π 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_GIDNNG_OPT_PEER_PIDNNG_OPT_PEER_UIDNNG_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
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms