NNG_STREAM_LISTENER_SET(3str)

πŸ“¦ version 1.11, in alpine 3.24

🌈 nng_stream_listener_set β€” set option on byte stream listener 🌈

okay bestie, welcome to the NNG_STREAM_LISTENER_SET(3str) page from the NNG Reference Manual. this is the one where we set options on a byte stream listener, and it’s lowkey a whole family of functions. let’s get into it πŸ’…

✨ NAME ✨

nng_stream_listener_set β€” set option on byte stream listener. that’s the main-character mission, fr fr πŸŽ€

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <nng/nng.h>

int nng_stream_listener_set(nng_stream_listener *l, const char *name, const void *data, size_t size);

int nng_stream_listener_set_bool(nng_stream_listener *l, const char *opt, bool val);

int nng_stream_listener_set_int(nng_stream_listener *l, const char *opt, int val);

int nng_stream_listener_set_ms(nng_stream_listener *l, const char *opt, nng_duration val);

int nng_stream_listener_set_ptr(nng_stream_listener *l, const char *opt, void *val);

int nng_stream_listener_set_size(nng_stream_listener *l, const char *opt, size_t val);

int nng_stream_listener_set_string(nng_stream_listener *l, const char *opt, const char *val);

int nng_stream_listener_set_uint64(nng_stream_listener *l, const char *opt, uint64_t val);

int nng_stream_listener_set_addr(nng_stream_listener *l, const char *opt, const nng_sockaddr *val);

πŸ’– DESCRIPTION πŸ’–

so the nng_stream_listener_set() functions are how you configure options for the byte stream listener l. which options can you set? it varies, bestie β€” the actual option is named by opt. a bunch of them are documented over in nng_options(5).

also, some transport-specific and protocol-specific options are documented with the transports and protocols themselves. so if you’re looking for the tea on a particular option, check that option’s own docs, iykyk 🌸

🌟 Forms 🌟

the type, the size, and the semantics of an option all depend on the actual option, and they’re documented with the option itself. so the option is basically the main character here πŸ‘‘

  • nng_stream_listener_set() β€” this one is untyped, and it can configure any arbitrary data. val points at the data to copy, and size is the size of the object located at val.
Note: this function is deprecated. use one of the typed forms instead, bestie 😭
  • nng_stream_listener_set_bool() β€” for options that take a Boolean (bool). cute and simple πŸŽ€
  • nng_stream_listener_set_int() β€” for options that take an integer (int). classic πŸ’…
  • nng_stream_listener_set_ms() β€” configures time durations (like timeouts) using the type nng_duration. the duration is an integer number of milliseconds. yes, milliseconds, write it down ✨
  • nng_stream_listener_set_ptr() β€” passes a pointer to structured data. the data referenced by it is 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: the object is generally <strong>not</strong> copied, but instead the pointer to the object is copied. please see the documentation for the specific option for further details, okay? 🫢
  • nng_stream_listener_set_size() β€” configures a size, typically for buffer sizes, message maximum sizes, and similar options. very size, very demure 🌸
  • nng_stream_listener_set_string() β€” configures a string. strings passed this way must be legal UTF-8 or ASCII strings, terminated with a NUL (\0) byte. other constraints may apply too, so see the documentation for each option for details πŸ¦‹
  • nng_stream_listener_set_uint64() β€” configures a 64-bit unsigned value. this is typically used for identifiers, network numbers, and similar options. big number energy πŸ”₯
  • nng_stream_listener_set_addr() β€” configures a socket address. the value is copied, so the caller may discard the supplied value immediately after this function returns. no need to cling to it, bestie πŸ’œ

⭐ RETURN VALUES ⭐

this function returns 0 on success, and non-zero otherwise. that’s the whole vibe check βœ…

🚨 ERRORS 🚨

  • NNG_ECLOSED β€” the listener is closed. she’s not available rn πŸ’€
  • NNG_EINVAL β€” either data or size are invalid. check those, bestie πŸ™ˆ
  • NNG_ENOTSUP β€” the option is not supported. not every option is invited to the party 😭
  • NNG_EREADONLY β€” the option may not be modified. read-only means read-only, periodt πŸ”’

πŸ‘‘ SEE ALSO πŸ‘‘


mwah πŸ’… this has been the NNG_STREAM_LISTENER_SET(3str) page from the NNG Reference Manual, dated 2026-01-13. go forth and set those options, bestie 🫢✨

πŸ“¦ where this page comes from