NNG_SOCKADDR_IN6(5)

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

✨ nng_sockaddr_in6(5) ✨

okay bestie, pull up a chair πŸ’– this is the NNG Reference Manual, section 5, and today's main character is nng_sockaddr_in6 β€” the IPv6 socket address. no cap, it's a whole vibe.


🌸 NAME 🌸

nng_sockaddr_in6 β€” IPv6 socket address πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <nng/nng.h>

enum sockaddr_family {
    NNG_AF_INET6 = 4,
};

typedef struct {
    uint16_t sa_family;
    uint16_t sa_port;
    uint8_t  sa_addr[16];
    uint32_t sa_scope;
} nng_sockaddr_in6;

like, that's literally the whole thing. short and iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so an nng_sockaddr_in6 is one specific flavor of nng_sockaddr, and it's the one you use to represent TCP addresses β€” and sometimes UDP addresses too β€” including the Internet Protocol (IP) address and the port number. it's giving "here's exactly where to find me on the network." ✨

this structure is the one for IPv6 addresses. for IPv4 you'd use a different structure, nng_sockaddr_in, because we do not mix those up in this house πŸ™ˆ

here are the members, bestie β€” one by one, no skipping:

  • sa_family β€” this field will always have the value NNG_AF_INET6. always. it never switches up on you, periodt.
  • sa_port β€” this holds the TCP or UDP port number, in network byte-order. and if there's no specific port number indicated? you get a zero value here. simple as that.
  • sa_addr β€” this field holds the IP address, in network byte-order.
  • sa_scope β€” this is the scope, and it's typically used with link local addresses to identify a specific interface. the details of it are specific to the operating system, so like, don't expect it to be cute and portable. this value is presented identically to the underlying system's, including any byte order considerations. iykyk 😭
πŸ’‘ Tip the sa_port and sa_addr fields are in network-byte order specifically so they play nice with system APIs like inet_ntop(). most platforms use some form of BSD-derived network API, and those use network-byte order in the various structures (such as sockaddr_in6). so it's a convenience thing, bestie 🫢
⚠️ Important yes, this field appears similar to the BSD sockaddr_in6 β€” but it is not the same, and they may not be used interchangeably. do not do the swap. do not try it. that is not the move πŸ’€

πŸ’œ SEE ALSO πŸ’œ

nng_sockaddr(5), nng_sockaddr_in(5), nng_tcp(7), nng(7)

go read those next, you'll be obsessed 🌈


and that's a wrap, bestie! this little gem came out of the NNG Reference Manual, dated 2026-06-30, and it goes by NNG_SOCKADDR_IN6(5) β€” iconic, honestly. stay safe out there and remember: network byte-order, not host byte-order. mwah πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from