NNG_STR_SOCKADDR(3)
π 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
- 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