NNG_DIALER_GETOPT(3)
π NNG_DIALER_GETOPT π
okay so bestie, we're in the NNG Reference Manual rn and today's episode is all about reading stuff back out of a dialer. yes. the whole page is literally called nng_dialer_getopt and it's giving "let me peek at your settings" energy. let's go π
β¨ NAME β¨
nng_dialer_getopt β get dialer option πΈ
β¨ SYNOPSIS β¨
#include <nng/nng.h>
int nng_dialer_getopt(nng_dialer d, const char *opt, void *val, size_t *valszp);
int nng_dialer_getopt_bool(nng_dialer d, const char *opt, bool *bvalp);
int nng_dialer_getopt_int(nng_dialer d, const char *opt, int *ivalp);
int nng_dialer_getopt_ms(nng_dialer d, const char *opt, nng_duration *durp);
int nng_dialer_getopt_ptr(nng_dialer d, const char *opt, void **ptr);
int nng_dialer_getopt_size(nng_dialer d, const char *opt, size_t *zp);
int nng_dialer_getopt_sockaddr(nng_dialer d, const char *opt, nng_sockaddr *sap);
int nng_dialer_getopt_string(nng_dialer d, const char *opt, char **strp);
int nng_dialer_getopt_uint64(nng_dialer d, const char *opt, uint64_t *u64p);
nine whole forms, we are fed π
β¨ DESCRIPTION β¨
β οΈ Important: these functions are deprecated. please go look atnng_dialer_getinstead, fr fr. also, they may not even be here if the library was built withNNG_ELIDE_DEPRECATED. so likeβ¦ vibe check before you commit π«
the nng_dialer_getopt() girlies are used to grab option values for the dialer d. which options you can actually pull this way? varies, bestie β a whole bunch of them are documented over in nng_options(5).
and additionally, some transport-specific options are documented with the transports themselves. iykyk π¦
π Forms π
in all of these forms, the option opt is retrieved from the dialer d. what changes between them is the type of the option they take.
the details of the type, the size, and the semantics of the option all depend on the actual option itself, and they'll be documented with the option itself. no guessing, periodt β¨
nng_dialer_getopt()β this one is untyped and can be used to retrieve the value of any option, which is lowkey iconic of it. the caller must store a pointer to a buffer to receive the value inval, and the size of the 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 sufficient space were present) is stored at the location referenced by valszp. if the caller's buffer is not large enough to hold the entire object, then the copy is truncated π. therefore the caller should validate that the returned size in valszp does not exceed the original buffer size, to check for truncation. do not skip this step, bestie.
it is acceptable to pass NULL for val if the value in valszp is zero. this can be used to determine the size of the buffer needed to receive the object. cute little trick, no cap.
π‘ Tip: it may be easier to use one of the typed forms of this function. just saying π
nng_dialer_getopt_bool()β for options which take a Boolean (bool). the value will be stored atbvalp. yes/no girlies rise πnng_dialer_getopt_int()β for options which take an integer (int). the value will be stored ativalp.nng_dialer_getopt_ms()β used to retrieve time durations (such as timeouts), stored indurpas a number of milliseconds. (the special valueNNG_DURATION_INFINITEmeans an infinite amount of time, and the special valueNNG_DURATION_DEFAULTmeans a context-specific default.) β³nng_dialer_getopt_ptr()β used to retrieve a pointer,ptr, to structured data. the data referenced byptris generally managed using other functions. note that this form is somewhat special in that the object is generally not copied β instead the pointer to the object is copied. it's giving "here's the address, not the vibes" πnng_dialer_getopt_size()β used to retrieve a size into the pointerzp, typically for buffer sizes, message maximum sizes, and similar options. πnng_dialer_getopt_sockaddr()β used to retrieve annng_sockaddrinto the value referenced bysap. πnng_dialer_getopt_string()β used to retrieve a string intostrp. 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. do NOT forget the free, that's a leak and the leak will find you πnng_dialer_getopt_uint64()β used to retrieve a 64-bit unsigned value into the value referenced byu64p. this is typically used for options related to identifiers, network numbers, and similar. big numbers, big slay π
β¨ RETURN VALUES β¨
these functions return 0 on success, and non-zero otherwise. that's it, that's the whole thing π«Ά
β¨ ERRORS β¨
NNG_EBADTYPEβ incorrect type for option. wrong shape, bestie, it doesn't fit π¬NNG_ECLOSEDβ parameterddoes not refer to an open dialer. she's closed, respectfully π€NNG_EINVALβ size of destinationvaltoo small for object. your buffer said "no <3" πNNG_ENOMEMβ insufficient memory exists. girl where is the RAM πNNG_ENOTSUPβ the optionoptis not supported. not a thing here, move along πNNG_EWRITEONLYβ the optionoptis write-only. you can set her but you cannot read her, and that's just the rules βοΈ
β¨ SEE ALSO β¨
nng_dialer_create(3)nng_dialer_setopt(3)nng_strdup(3)nng_strerror(3)nng_strfree(3)nng_dialer(5)nng_duration(5)nng_options(5)nng_sockaddr(5)nng(7)
and that's the whole page babes π this was NNG_DIALER_GETOPT, served fresh on 2026-06-30, straight from the NNG Reference Manual (version tag and all, she's stamped and certified). go forth, get your options, and remember: deprecated but still documented. mwah πβ¨
π¦ 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