NNG_DIALER_GETOPT(3)

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

πŸ’– 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 at nng_dialer_get instead, fr fr. also, they may not even be here if the library was built with NNG_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 in val, and the size of the buffer shall be stored at the location referenced by valszp.

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 at bvalp. yes/no girlies rise πŸŽ€
  • nng_dialer_getopt_int() β€” for options which take an integer (int). the value will be stored at ivalp.
  • nng_dialer_getopt_ms() β€” used to retrieve time durations (such as timeouts), stored in durp as a number of milliseconds. (the special value NNG_DURATION_INFINITE means an infinite amount of time, and the special value NNG_DURATION_DEFAULT means a context-specific default.) ⏳
  • nng_dialer_getopt_ptr() β€” used to retrieve a pointer, ptr, to structured data. the data referenced by ptr is 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 pointer zp, typically for buffer sizes, message maximum sizes, and similar options. πŸ“
  • nng_dialer_getopt_sockaddr() β€” used to retrieve an nng_sockaddr into the value referenced by sap. 🌐
  • nng_dialer_getopt_string() β€” used to retrieve a string into strp. this string is created from the source using nng_strdup() and consequently must be freed by the caller using nng_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 by u64p. 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 β€” parameter d does not refer to an open dialer. she's closed, respectfully πŸ’€
  • NNG_EINVAL β€” size of destination val too small for object. your buffer said "no <3" πŸ“
  • NNG_ENOMEM β€” insufficient memory exists. girl where is the RAM 😭
  • NNG_ENOTSUP β€” the option opt is not supported. not a thing here, move along πŸ™…
  • NNG_EWRITEONLY β€” the option opt is write-only. you can set her but you cannot read her, and that's just the rules ✍️

✨ SEE ALSO ✨


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