NNG_STREAM_LISTENER_GET(3str)

πŸ“¦ version 1.11, in alpine 3.24

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 in val, and the size of the buffer shall be stored at the location referenced by sizep.

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 value NNG_DURATION_INFINITE means an infinite amount of time, and the special value NNG_DURATION_DEFAULT means 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 a NULL-terminated string. 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. 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 in sizep. 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