NNG_SOCKADDR_IN(5)
π nng_sockaddr_in(5) π
okay bestie, welcome to the NNG Reference Manual, page for nng_sockaddr_in β yes that's the manual section 5, and yes we're gonna make IPv4 addresses make sense together π«Ά
β¨ NAME β¨
nng_sockaddr_in β IPv4 socket address πΈ
β¨ SYNOPSIS β¨
#include <nng/nng.h>
enum sockaddr_family {
NNG_AF_INET = 3,
};
typedef struct {
uint16_t sa_family;
uint16_t sa_port;
uint32_t sa_addr;
} nng_sockaddr_in;
like. look at her. three little fields. iconic π
β¨ DESCRIPTION β¨
so an nng_sockaddr_in is the flavor of nng_sockaddr that's used to represent TCP (and sometimes UDP) addresses β that means it holds both the Internet Protocol (IP) address and the port number. two for one, we love a multitasker π
this structure is the one for IPv4 addresses, periodt. there's a whole different structure for IPv6 addresses, and that one is nng_sockaddr_in6. do not mix them up, bestie, i'm begging π
here's every member, no gatekeeping:
sa_familyβ this field will always have the valueNNG_AF_INET. always always. it's committed πsa_portβ this field holds the TCP or UDP port number, in network byte-order. and listen: a zero value here is used when no specific port number is indicated.sa_addrβ this field holds the IP address in network-byte order.
Tip π thesa_portandsa_addrfields are in network-byte order to facilitate their use with system APIs such asinet_ntop(). most platforms use some form of BSD-derived network API, which uses network-byte order in the various structures (such assockaddr_in). so it's not weird, it's on purpose, iykyk β¨
Important β οΈ this field appears similar to BSD sockaddr_in, BUT it is not the same, and they may not be used interchangeably. i know they look like twins. they are not twins. do not swap them. this is the warning, this is the moment π
β¨ SEE ALSO β¨
go read those next, we're building a whole β¨ecosystemβ¨ π¦
and that's the page!! mwah π this one's from the NNG fam, dated 2026-06-30, and it's literally titled NNG_SOCKADDR_IN(5) at the bottom of the original β so consider yourself signed off on, angel πβ
π¦ 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