NNG_STREAM_LISTENER_GET(3str)
okay bestie, welcome to nng_stream_listener_get from the NNG Reference Manual, 3str section π this is the page where you grab option values off a byte stream listener, and yes, there are a lot of typed forms. stay with me, it's giving thorough π
πΈ NAME πΈ
nng_stream_listener_get β get an option from a byte stream listener π
β¨ SYNOPSIS β¨
#include <nng/nng.h>
int nng_stream_listener_get(nng_stream_listener *l, const char *opt, void *val, size_t *sizep);
int nng_stream_listener_get_bool(nng_stream_listener *l, const char *opt, bool *valp);
int nng_stream_listener_get_int(nng_stream_listener *l, const char *opt, int *valp);
int nng_stream_listener_get_ms(nng_stream_listener *l, const char *opt, nng_duration *valp);
int nng_stream_listener_get_ptr(nng_stream_listener *l, const char *opt, void **valp);
int nng_stream_listener_get_size(nng_stream_listener *l, const char *opt, size_t *valp);
int nng_stream_listener_get_addr(nng_stream_listener *l, const char *opt, nng_sockaddr *valp);
int nng_stream_listener_get_string(nng_stream_listener *l, const char *opt, char **valp);
int nng_stream_listener_get_uint64(nng_stream_listener *l, const char *opt, uint64_t *valp);
π¦ DESCRIPTION π¦
The nng_stream_listener_get() functions are the whole vibe check for retrieving option values from the byte stream listener l π
Which options you can actually retrieve this way varies, bestie. A number of them are documented in nng_options(5) and additional linked documents. 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, always check that option's own docs π
π Forms π
In all of these forms, the option opt is retrieved from the connected byte stream listener l. The forms vary based on the type of the option they take. 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. literally the option is the main character here π
nng_stream_listener_get()β this function is untyped and can be used to retrieve the value of any option. 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 bysizep.
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 sizep. If the callerβs buffer is not large enough to hold the entire object, then the copy is truncated. Therefore the caller should check for truncation by verifying that the returned size in sizep does not exceed the original buffer size. so likeβ¦ peek at sizep, bestie π«Ά
It is acceptable to pass NULL for val if the value in sizep is zero. This can be used to determine the size of the buffer needed to receive the object. very useful, very iconic β¨
β οΈ Note: This function is deprecated. Use one of the typed functions below instead. no cap, it's giving legacy π
nng_stream_listener_get_bool()β this function is for options which take a Boolean (bool). true/false girlies rise πnng_stream_listener_get_int()β this function is for options which take an integer (int). whole-number behavior π’nng_stream_listener_get_ms()β this function is used to retrieve time durations (such as timeouts), stored as a number of milliseconds. (The special valueNNG_DURATION_INFINITEmeans an infinite amount of time, and the special valueNNG_DURATION_DEFAULTmeans a context-specific default.) time math, but make it cute β³nng_stream_listener_get_ptr()β this function is used to retrieve a pointer to structured data. The data referenced is generally managed using other functions. Note that this form is somewhat special in that the object is generally not copied, but instead the pointer to the object is copied. pointer energy, but be careful π
β οΈ Note: Care must be taken to ensure that the application respects any considerations about the lifetime of the underlying object. See the documentation for the option for more specific guidance. do not let it dangle, bestie π
nng_stream_listener_get_size()β this function is used to retrieve a size, typically for buffer sizes, message maximum sizes, and similar options. sizes, sizes, sizes πnng_stream_listener_get_addr()β this function is used to retrieve a socket address. address reveal πnng_stream_listener_get_string()β this function is used to retrieve aNULL-terminated string. 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. free it when you're done, fr fr π§nng_stream_listener_get_uint64()β this function is used to retrieve a 64-bit unsigned value. This is typically used for identifiers, network numbers, and similar options. big unsigned numbers, big slay π₯
π RETURN VALUES π
These functions return 0 on success, and non-zero otherwise. zero means we ate, anything else means check the errors below π
π ERRORS π
NNG_ECLOSEDβ the listener is closed. she's gone, bestie πͺNNG_EINVALβ there was insufficient space to receive the object. The amount of data actually needed is returned insizep. buffer said "not today" πNNG_ENOTSUPβ the option is not supported. not every option is invited to the party πNNG_EWRITEONLYβ the option may not read. write-only behavior, no reading allowed π
π SEE ALSO π
mwah π this gem is from the NNG Reference Manual, dated 2026-01-13, page NNG_STREAM_LISTENER_GET(3str) β go forth and get those options, bestie π«Άβ¨
π¦ where this page comes from
- alpine 3.24: nng-doc 1.11-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms