NNG_PIPE_GETOPT(3)
π NNG_PIPE_GETOPT(3) π
okay bestie, so this one lives in the NNG Reference Manual and it's literally called nng_pipe_getopt β the "get pipe option" girlie β¨
πΈ NAME πΈ
nng_pipe_getopt β get pipe option π
π SYNOPSIS π
#include <nng/nng.h>
int nng_pipe_getopt(nng_pipe p, const char *opt, void *val, size_t *valszp);
int nng_pipe_getopt_bool(nng_pipe p, const char *opt, bool *bvalp);
int nng_pipe_getopt_int(nng_pipe p, const char *opt, int *ivalp);
int nng_pipe_getopt_ms(nng_pipe p, const char *opt, nng_duration *durp);
int nng_pipe_getopt_ptr(nng_pipe p, const char *opt, void **ptr);
int nng_pipe_getopt_sockaddr(nng_pipe p, const char *opt, nng_sockaddr *sap);
int nng_pipe_getopt_string(nng_pipe p, const char *opt, char **strp);
int nng_pipe_getopt_size(nng_pipe p, const char *opt, size_t *zp);
int nng_pipe_getopt_uint64(nng_pipe p, const char *opt, uint64_t *u64p);
π¦ DESCRIPTION π¦
Note β bestie these functions are deprecated. π Please see nng_pipe_get instead.
The nng_pipe_getopt() functions are your little retrieval squad for pulling option values off the pipe p. Which options you can actually grab this way varies, and a whole bunch of them are documented over in nng_options(5). On top of that, some transport-specific options and protocol-specific options are documented right alongside the transports and protocols themselves. iykyk π
Note β okay so all options on a pipe are read-only values, periodt. If you wanna modify options, you gotta do it before the pipe is even created, usingnng_listener_setopt()ornng_dialer_setopt(). π«Ά
Any option that gets set on a dialer or listener will normally be retrievable from pipes created by that dialer or listener. iconic π
β¨ Forms β¨
In all of these forms, the option opt is retrieved from the pipe p. π
The details of the type, size, and semantics of the option will depend on the actual option, and will be documented with the option itself. no cap.
nng_pipe_getopt()β this one is untyped, and it can be used to retrieve the value of any option. You pass a pointer to a buffer to receive the value inval, and the size of that buffer shall be stored at the location referenced byvalszp. π¦ When the function returns, the actual size of the data copied (or that would have been copied if there were enough space) gets stored at the location referenced byvalszp. Watch out though: if the caller's buffer isn't large enough to hold the entire object, the copy gets truncated. π So the caller should check for truncation by verifying that the size returned invalszpdoes not exceed the original buffer size. fr fr. It is acceptable to passNULLforvalif the value invalszpis zero. This can be used to determine the size of the buffer needed to receive the object. π₯
Tip β honestly it may be easier to use one of the typed forms of this function. just saying π
nng_pipe_getopt_bool()β this one's for options that take a Boolean (bool). The value will be stored atbvalp. βnng_pipe_getopt_int()β this one's for options that take an integer (int). The value will be stored ativalp. π’nng_pipe_getopt_ms()β this one's for retrieving time durations (nng_duration) in milliseconds, which get stored indurp. β±οΈnng_pipe_getopt_ptr()β this one's for retrieving a pointerptrto structured data. The data referenced byptris generally managed using other functions. Note that this form is kinda special, lowkey, because the object is generally not copied β instead the pointer to the object is copied. πnng_pipe_getopt_size()β this one's for retrieving a size into the pointerzp, typically for buffer sizes, message maximum sizes, and similar options. πnng_pipe_getopt_sockaddr()β this one's for retrieving annng_sockaddrintosap. πnng_pipe_getopt_string()β this one's for retrieving a string intostrp. Heads up bestie: this string is created from the source usingnng_strdup()and consequently must be freed by the caller usingnng_strfree()when it is no longer needed. don't leak, that's not the vibe πnng_pipe_getopt_uint64()β this one's for retrieving a 64-bit unsigned value into the value referenced byu64p. This is typically used for options related to identifiers, network numbers, and similar. π§
π RETURN VALUES π
These functions return 0 on success, and non-zero otherwise. simple as that π
π ERRORS π
NNG_EBADTYPEβ Incorrect type for option.NNG_ECLOSEDβ Parameterpdoes not refer to an open pipe.NNG_ENOTSUPβ The optionoptis not supported.NNG_ENOMEMβ Insufficient memory exists.NNG_EINVALβ Size of destinationvaltoo small for object.NNG_EWRITEONLYβ The optionoptis write-only.
π SEE ALSO π
nng_dialer_setopt(3) nng_getopt(3), nng_listener_setopt(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)
aaaand that's the whole page bestie!! π«Άπ this iconic little number came from the NNG Reference Manual, dated 2026-06-30. slay, go read nng_pipe_get instead tho, 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