NNG_PIPE_GET(3)
β¨ NNG_PIPE_GET(3) β¨
okay bestie, welcome to nng_pipe_get from the NNG Reference Manual π this is the one where we read stuff off a pipe, no cap.
πΈ NAME πΈ
nng_pipe_get β get pipe option. that's it, that's the whole vibe π
π¦ SYNOPSIS π¦
#include <nng/nng.h>
int nng_pipe_get(nng_pipe p, const char *opt, void *val, size_t *valszp);
int nng_pipe_get_bool(nng_pipe p, const char *opt, bool *bvalp);
int nng_pipe_get_int(nng_pipe p, const char *opt, int *ivalp);
int nng_pipe_get_ms(nng_pipe p, const char *opt, nng_duration *durp);
int nng_pipe_get_ptr(nng_pipe p, const char *opt, void **ptr);
int nng_pipe_get_addr(nng_pipe p, const char *opt, nng_sockaddr *sap);
int nng_pipe_get_string(nng_pipe p, const char *opt, char **strp);
int nng_pipe_get_size(nng_pipe p, const char *opt, size_t *zp);
int nng_pipe_get_uint64(nng_pipe p, const char *opt, uint64_t *u64p);
π DESCRIPTION π
so the nng_pipe_get() functions are literally how you pull option values off the pipe p. π which options you can grab this way? it varies, babes β a whole bunch of them live in nng_options(5), and also some transport-specific options and protocol-specific options are documented with the transports and protocols themselves. iykyk π«Ά
Note β every single option on a pipe is read-only. if you wanna modify options, you gotta do it before the pipe even exists, usingnng_listener_set()ornng_dialer_set(). periodt. π
also: any option that's set on a dialer or listener will normally be retrievable from pipes created by that dialer or listener. cute, right? β¨
π Forms π
in every one of these forms, the option opt gets retrieved from the pipe p.
the type, size, and semantics of the option? depends entirely on the actual option, and it's documented with the option itself. no guessing here bestie π
nng_pipe_get()β this one is untyped and can fetch the value of any option. you hand itval, a pointer to the buffer that'll receive the value, andvalszp, the location where the buffer size is stored.
when the function comes back, the location referenced by valszp holds the actual size of the data that got copied (or that would have been copied if there'd been enough room π). if your buffer isn't big enough to hold the whole object, the copy gets truncated. so pls, check for truncation by verifying that the size returned in valszp does not exceed your original buffer size. do not skip this, fr fr π
it's totally acceptable to pass NULL for val when the value in valszp is zero. that trick lets you figure out how big a buffer you actually need. main character energy π
Tip β it may be easier to use one of the typed forms of this function. just saying π
nng_pipe_get_bool()β for options that take a Boolean (bool). the value lands atbvalp. βnng_pipe_get_int()β for options that take an integer (int). the value lands ativalp. π’nng_pipe_get_ms()β retrieves time durations (nng_duration) in milliseconds, stored indurp. β±οΈnng_pipe_get_ptr()β retrieves a pointer,ptr, to structured data. the data thatptrpoints at is generally managed using other functions. note this form is somewhat special: the object is generally not copied, instead the pointer to the object is copied. π³ big difference, okay?nng_pipe_get_size()β retrieves a size into the pointerzp. typically for buffer sizes, message maximum sizes, and similar options. πnng_pipe_get_addr()β retrieves annng_sockaddrintosap. πnng_pipe_get_string()β retrieves a string intostrp. heads up: this string is created from the source usingnng_strdup()and consequently must be freed by the caller usingnng_strfree()when it's no longer needed. don't leak, bestie πnng_pipe_get_uint64()β retrieves a 64-bit unsigned value into the value referenced byu64p. typically used for options related to identifiers, network numbers, and similar. π§
β RETURN VALUES β
these functions return 0 on success, and non-zero otherwise. that's the whole thing π
π ERRORS π
NNG_EBADTYPEβ incorrect type for option. wrong vibe, wrong shape πNNG_ECLOSEDβ parameterpdoes not refer to an open pipe. it's giving closed, bestie πNNG_ENOENTβ parameterpdoes not refer to an existing pipe. doesn't exist. nowhere. gone. πNNG_ENOTSUPβ the optionoptis not supported. not on the menu π«NNG_ENOMEMβ insufficient memory exists. out of RAM, out of luck π§οΈNNG_EINVALβ size of destinationvaltoo small for object. you said no to truncation, remember? πNNG_EWRITEONLYβ the optionoptis write-only. you can write it, you just can't read it. the audacity π€
π SEE ALSO π
nng_dialer_set(3) nng_socket_get(3), nng_listener_set(3) nng_msg_get_pipe(3) nng_strdup(3), nng_strerror(3), nng_strfree(3), nng_duration(5), nng_options(5), nng_pipe(5), nng_sockaddr(5), nng(7)
and that's the page, bestie π«Ά this was NNG_PIPE_GET(3) from the NNG Reference Manual, dated 2026-06-30 β go forth and read those options, you absolute icon ππβ¨
π¦ 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