NNG_STR_SOCKADDR(3)

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

πŸ’– NNG_STR_SOCKADDR(3) πŸ’–

okay bestie, welcome to the NNG Reference Manual ✨ you're literally about to learn how to turn a socket address into something your eyeballs can actually read. no cap.


🌸 NAME 🌸

nng_str_sockaddr β€” get the string representation of a socket address πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <nng/nng.h>

#define NNG_MAXADDRSTRLEN (NNG_MAXADDRLEN+16)
const char *nng_str_sockaddr(const nng_sockaddr *sa, char *buf, size_t bufsz)

✨ DESCRIPTION ✨

so like, nng_str_sockaddr() is the glow-up function 🫢 β€” it takes the socket address sa and gives you a displayable representation of it. the content gets stored at the location you handed over in buf, and it's formatted to fit inside bufsz bytes. if it doesn't fit? it gets truncated. sad but true 😭

as long as bufsz is greater than zero, the result is gonna be properly zero-terminated in the usual fashion, so don't even stress about that part πŸ’–

NNG_MAXADDRSTRLEN exists so you can make a buffer big enough to hold most socket addresses. and yes, technically applications can use very much larger socket addresses (like, very long paths for IPC or inproc πŸ‘€), but heads up β€” those addresses are not generally compatible with other implementations, and they'll get truncated right here. it's giving "you can do it but why would you" πŸ’€


πŸŽ€ RETURN VALUES πŸŽ€

this function returns the buf argument. that's it, that's the whole return value. iconic behavior honestly πŸ‘‘


🌈 ERRORS 🌈

None. not a single one. she doesn't do errors, she does vibes ✨


πŸ’œ SEE ALSO πŸ’œ


that's the whole page bestie, go forth and stringify those sockaddrs πŸ§šβ€β™€οΈ

β€” NNG Reference Manual, dated 2026-06-30 πŸ’Œ mwah, slay, periodt πŸ’…

πŸ“¦ where this page comes from