NNG_LISTENER_SET(3)

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

πŸ’– NAME πŸ’–

nng_listener_set β€” set listener option, bestie πŸ’…

This one lives in the NNG Reference Manual, section 3, and it's literally the glow-up wand for your listener's settings.


✨ SYNOPSIS ✨

#include <nng/nng.h>

int nng_listener_set(nng_listener l, const char *opt, const void *val,
    size_t valsz);

int nng_listener_set_bool(nng_listener l, const char *opt, bool bval);

int nng_listener_set_int(nng_listener l, const char *opt, int ival);

int nng_listener_set_ms(nng_listener l, const char *opt, nng_duration dur);

int nng_listener_set_ptr(nng_listener l, const char *opt, void *ptr);

int nng_listener_set_size(nng_listener l, const char *opt, size_t z);

int nng_listener_set_string(nng_listener l, const char *opt, const char *str);

int nng_listener_set_uint64(nng_listener l, const char *opt, uint64_t u64);

πŸŽ€ DESCRIPTION πŸŽ€

Okay so the nng_listener_set() functions are how you configure options for the listener l. Which options can actually be set this way? It varies, babes β€” and a lot of them are documented over in nng_options(5).

On top of that, some transport-specific options are documented right alongside the transports themselves. iykyk. πŸ’œ

Note 🫢 Once a listener has started, it is generally not possible to change its configuration. So like… pick your vibe before you hit go, fr fr.

🌈 Forms

In every single one of these forms, the option opt is configured on the listener l.

The actual type, size, and semantics of the option depend on the option itself β€” it'll be documented with the option. No guessing, bestie πŸ’…

nng_listener_set()

This one is untyped, and it can configure literally any arbitrary data. The val pointer addresses the data to copy, and valsz is the size of the object located at val.

Note 😭 This function is deprecated. Use one of the typed functions below instead. She's retiring, let her rest.

nng_listener_set_bool()

For options that take a Boolean (bool). The bval gets passed straight to the option. true/false, iconic, no notes. βœ…

nng_listener_set_int()

For options that take an integer (int). The ival is passed to the option. πŸ”₯

nng_listener_set_ms()

This one configures time durations (think timeouts) using type nng_duration. The duration dur is an integer number of milliseconds. She said time is fake but milliseconds are real ⏱️

nng_listener_set_ptr()

Used to pass a pointer, ptr, to structured data. The data referenced by ptr 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 a lil special: the object is generally not copied β€” instead the pointer to the object is copied. Careful with ownership, bestie.

nng_listener_set_size()

Configures a size, z β€” typically for buffer sizes, message maximum sizes, and similar options. Big number energy πŸ“

nng_listener_set_string()

Used to configure a string, str. Strings passed this way must be legal UTF-8 or ASCII strings, terminated with a NUL (\0) byte. (Other constraints may apply as well β€” check the docs for each option for the deets.) πŸŽ€

nng_listener_set_uint64()

Configures a 64-bit unsigned value, u64. Typically used for options related to identifiers, network numbers, and similar. Huge. Massive. 64 bits of pure slay πŸ‘‘


⭐ RETURN VALUES ⭐

These functions return 0 on success, and non-zero otherwise. Simple as. πŸ’–


πŸ”₯ ERRORS πŸ”₯

  • NNG_EBADTYPE β€” Incorrect type for option. She's not that kind of girl, bestie.
  • NNG_ECLOSED β€” Parameter l does not refer to an open listener. It's giving… closed. 😭
  • NNG_EINVAL β€” The value being passed is invalid. Nope, not vibing.
  • NNG_ENOTSUP β€” The option opt is not supported. We simply don't do that here πŸ’…
  • NNG_EREADONLY β€” The option opt is read-only. Look, don't touch, iconic πŸ’€
  • NNG_ESTATE β€” The listener l is already started. Too late, she's already out the door πŸšͺ

🌸 SEE ALSO 🌸


And that's the whole page, bestie 🫢 β€” this was NNG_LISTENER_SET(3) from the NNG Reference Manual, dated 2026-06-30. Go set some options, but respectfully. βœ¨πŸ’…πŸŒΈ

πŸ“¦ where this page comes from