NNG_LISTENER_SETOPT(3)
π NNG_LISTENER_SETOPT(3) π
okay bestie, so this page is literally from the NNG Reference Manual, and it's all about the nng_listener_setopt family of functions. Let's get into it β¨
β¨ NAME β¨
nng_listener_setopt β set listener option π
πΈ SYNOPSIS πΈ
#include <nng/nng.h>
int nng_listener_setopt(nng_listener l, const char *opt, const void *val,
size_t valsz);
int nng_listener_setopt_bool(nng_listener l, const char *opt, bool bval);
int nng_listener_setopt_int(nng_listener l, const char *opt, int ival);
int nng_listener_setopt_ms(nng_listener l, const char *opt, nng_duration dur);
int nng_listener_setopt_ptr(nng_listener l, const char *opt, void *ptr);
int nng_listener_setopt_size(nng_listener l, const char *opt, size_t z);
int nng_listener_setopt_string(nng_listener l, const char *opt, const char *str);
int nng_listener_setopt_uint64(nng_listener l, const char *opt, uint64_t u64);
π DESCRIPTION π
Important π¨ These functions are deprecated. Please seenng_listener_set. They may not be present if the library was built withNNG_ELIDE_DEPRECATED.
The nng_listener_setopt() functions are how you configure options for the listener l. Which options you can actually configure this way varies, and a whole bunch of them are documented over in nng_options(5).
Also, some transport-specific options are documented with the transports themselves, so go check those out π
Note π Once a listener has started, it is generally not possible to change its configuration. It's giving "locked in" energy, but not in a fun way.
π¦ Forms π¦
In all of these forms, the option opt gets configured on the listener l.
The details of the type, size, and semantics of the option depend on the actual option itself, and they get documented alongside that option. iykyk π
Tip β¨ It may be easier to use one of the typed forms of this function. Just saying.
nng_listener_setopt()β This one is untyped, so it can configure literally any arbitrary data. Thevalpointer addresses the data to copy, andvalszis the size of the object located atval. (Yes, the original says "objected", we're all doing our best π)nng_listener_setopt_bool()β For options that take a Boolean (bool). Thebvalgets passed to the option. true/false queen πnng_listener_setopt_int()β For options that take an integer (int). Theivalgets passed to the option.nng_listener_setopt_ms()β Used to configure time durations (think timeouts) using typenng_duration. The durationduris an integer number of milliseconds β±οΈnng_listener_setopt_ptr()β Used to pass a pointer,ptr, to structured data. The data referenced byptris generally managed by other functions. For example, TLS configuration objects created with(nng_tls_config_alloc())can be passed this way π
Note π This form is somewhat special in that the object is generally not copied β instead, the pointer to the object is copied.
nng_listener_setopt_size()β Used to configure a size,z, typically for buffer sizes, message maximum sizes, and similar options. Big things, small things, all the things πnng_listener_setopt_string()β Used to configure a string,str. Strings passed this way must be legal UTF-8 or ASCII strings, terminated with aNUL(\0) byte. (Other constraints may apply as well β see the documentation for each option for details.) No random bytes pls πnng_listener_setopt_uint64()β Used to configure a 64-bit unsigned value,u64. This is typically used for options related to identifiers, network numbers, and similar. Big number energy π’
π₯ RETURN VALUES π₯
These functions return 0 on success, and non-zero otherwise. She ate when she succeeds, and she's being dramatic otherwise π
π ERRORS π
NNG_EBADTYPEβ Incorrect type for option.NNG_ECLOSEDβ Parameterldoes not refer to an open listener.NNG_EINVALβ The value being passed is invalid.NNG_ENOTSUPβ The optionoptis not supported.NNG_EREADONLYβ The optionoptis read-only. bestie you cannot write to that, it said no π«NNG_ESTATEβ The listenerlis already started.
π SEE ALSO π
nng_listen(3)nng_listener_create(3)nng_listener_getopt(3)nng_setopt(3)nng_strerror(3)nng_duration(5)nng_listener(5)nng_options(5)nng(7)
and that's the whole page bestie, no cap π«Ά this was the NNG Reference Manual, dated 2026-06-30, filed under NNG_LISTENER_SETOPT(3) β¨ go configure responsibly ππ
π¦ 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