NNG_LISTENER_SETOPT(3)

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

πŸ’– 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 see nng_listener_set. They may not be present if the library was built with NNG_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. The val pointer addresses the data to copy, and valsz is the size of the object located at val. (Yes, the original says "objected", we're all doing our best πŸ™ˆ)
  • nng_listener_setopt_bool() β€” For options that take a Boolean (bool). The bval gets passed to the option. true/false queen πŸ’…
  • nng_listener_setopt_int() β€” For options that take an integer (int). The ival gets passed to the option.
  • nng_listener_setopt_ms() β€” Used to configure time durations (think timeouts) using type nng_duration. The duration dur is an integer number of milliseconds ⏱️
  • nng_listener_setopt_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 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 a NUL (\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 β€” Parameter l does not refer to an open listener.
  • NNG_EINVAL β€” The value being passed is invalid.
  • NNG_ENOTSUP β€” The option opt is not supported.
  • NNG_EREADONLY β€” The option opt is read-only. bestie you cannot write to that, it said no 🚫
  • NNG_ESTATE β€” The listener l is already started.

πŸ‘‘ SEE ALSO πŸ‘‘


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