NNG_SOCKADDR_IN(5)

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

πŸ’– 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 value NNG_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 πŸŽ€ the sa_port and sa_addr fields are in network-byte order to facilitate their use with system APIs such as inet_ntop(). most platforms use some form of BSD-derived network API, which uses network-byte order in the various structures (such as sockaddr_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