NNG_SOCKADDR(5)

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

πŸ’– NNG_SOCKADDR πŸ’–

okay bestie, gather round, we're talking about nng_sockaddr, the socket address situation. this is from the NNG Reference Manual, page NNG_SOCKADDR(5), and it's giving "I contain multitudes." let's get into it ✨


🌸 SYNOPSIS 🌸

#include <nng/nng.h>

typedef union nng_sockaddr {
    uint16_t              s_family;
    nng_sockaddr_ipc      s_ipc;
    nng_sockaddr_inproc   s_inproc;
    nng_sockaddr_in       s_in;
    nng_sockaddr_in6      s_in6;
    nng_sockaddr_zt       s_zt;
    nng_sockaddr_abstract s_abstract;
} nng_sockaddr;

enum sockaddr_family {
    NNG_AF_UNSPEC   = 0,
    NNG_AF_INPROC   = 1,
    NNG_AF_IPC      = 2,
    NNG_AF_INET     = 3,
    NNG_AF_INET6    = 4,
    NNG_AF_ZT       = 5,
    NNG_AF_ABSTRACT = 6
};

πŸ¦‹ DESCRIPTION πŸ¦‹

so an nng_sockaddr is this structure that's used for representing the addresses that the underlying transports use β€” think TCP/IP addresses, IPC paths, all of that πŸ’…

real talk: the name sockaddr is based on how similar it is to POSIX struct sockaddr, but ngl in NNG these addresses are way more closely affiliated with instances of nng_pipe than of nng_socket. the naming confusion is, and I quote, unfortunate. 😭 we don't make the rules bestie, we just read the manpage.

okay so this thing is actually a union, right? it's got different members for different types of addresses. union girlie. she contains multitudes. πŸ‘‘

every single one of those member structures has, as its very first element, a uint16_t field holding the address family. that field overlaps with the s_family member of the union, and it's the thing that tells you which specific member you should actually be using. it's like the little name tag at the party πŸŽ€

the values of s_family are, in order:

  • NNG_AF_UNSPEC β€” invalid address, no other valid fields. it's giving "no thoughts, head empty." πŸ«₯
  • NNG_AF_INPROC β€” address for intraprocess communication (nng_inproc(7)). the s_inproc member is the valid one. ✨
  • NNG_AF_IPC β€” address for interprocess communication (nng_ipc(7)). the s_path member is the valid one. 🌈
  • NNG_AF_INET β€” address for TCP/IP (v4) communication. the s_in member is the valid one. πŸ”₯
  • NNG_AF_INET6 β€” address for TCP/IP (v6) communication. the s_in6 member is the valid one. ⭐
  • NNG_AF_ZT β€” address for the ZeroTier transport (nng_zerotier(7)). the s_zt member is the valid one. πŸ’œ
  • NNG_AF_ABSTRACT β€” address for an abstract UNIX domain socket. the s_abstract member is the valid one. πŸ¦‹

and like, pls go read the manual pages for each individual type for the full scoop, because this page is just the vibe check, not the whole story. iykyk 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

nng_sockaddr_abstract(5), nng_sockaddr_in(5), nng_sockaddr_in6(5), nng_sockaddr_inproc(5), nng_sockaddr_ipc(5), nng_sockaddr_zt(5), nng(7)


okay that's the whole page, bestie, you ate that πŸ“ this was the NNG Reference Manual situation, NNG_SOCKADDR(5), dated 2026-06-30. go forth and address things correctly. mwah πŸ’–βœ¨

πŸ“¦ where this page comes from