NNG_CTX_SET(3)

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

🌸 nng_ctx_set β€” setting context options, the glow-up edition 🌸

okay so bestie, this page is from the NNG Reference Manual β€” NNG_CTX_SET(3), manual section 3, the functions-and-subroutines girlies. sit with me, we're doing options today. πŸ’–


✨ NAME ✨

nng_ctx_set β€” set context option. that's it, that's the whole vibe. πŸŽ€


✨ SYNOPSIS ✨

#include <nng/nng.h>

int nng_ctx_set(nng_ctx ctx, const char *opt, const void *val, size_t valsz);

int nng_ctx_set_bool(nng_ctx ctx, const char *opt, int bval);

int nng_ctx_set_int(nng_ctx ctx, const char *opt, int ival);

int nng_ctx_set_ms(nng_ctx ctx, const char *opt, nng_duration dur);

int nng_ctx_set_size(nng_ctx ctx, const char *opt, size_t z);

int nng_ctx_set_string(nng_ctx ctx, const char *opt, const char *str);

int nng_ctx_set_uint64(nng_ctx ctx, const char *opt, uint64_t u64);

look at that family. seven siblings, all serving. πŸ’…


✨ DESCRIPTION ✨

Note β€” these functions are deprecated. Please see nng_ctx_set. (yes bestie, it points at itself, that is genuinely what the page says, I'm just the messenger 🫠)

so. the nng_ctx_set() functions are how you configure options for the context ctx. which options you can actually set this way? varies! it's specified by opt. that's the argument doing all the heavy lifting. πŸ‘‘

Note β€” context options are protocol specific. the deets get documented with the protocol, not here. so go read your protocol's page, bestie, I can't manifest that information for you. πŸ™ˆ

🌈 Forms 🌈

the type, the size, and the semantics of an option all depend on the actual option itself, and they get documented with that option. every option carries its own lore, iykyk.

  • nng_ctx_set() β€” this one is untyped, a total free spirit, and it can configure literally any arbitrary data. val points at the data you're copying, and valsz is the size of the object sitting at val. no type checking, all trust.
Tip β€” it might be easier to just use one of the typed forms of this function. lowkey the typed girlies are more chill. ✨
  • nng_ctx_set_bool() β€” for options that take a Boolean (bool). bval gets passed to the option. true/false moment, no in-between. πŸ¦‹
  • nng_ctx_set_int() β€” for options that take an integer (int). ival gets passed to the option.
  • nng_ctx_set_ms() β€” for configuring time durations, like timeouts, using type nng_duration. the duration dur is an integer number of milliseconds. ⏱️ she's measuring in ms, she's precise, she's on time.
  • nng_ctx_set_size() β€” for configuring a size, z. typically buffer sizes, message maximum sizes, and similar options. the bigger-the-better aesthetic. πŸ’…
  • nng_ctx_set_string() β€” for configuring 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 too β€” check the documentation for each option for the details.) 🌸
  • nng_ctx_set_uint64() β€” for configuring a 64-bit unsigned value, u64. typically used for options related to identifiers, network numbers, and similar. big number energy, honestly iconic. πŸ”₯

✨ RETURN VALUES ✨

these functions return 0 on success, and non-zero otherwise. zero means slay, anything else means go read the ERRORS section. 😭


✨ ERRORS ✨

  • NNG_ECLOSED β€” parameter s does not refer to an open socket.
  • NNG_EINVAL β€” the value being passed is invalid.
  • NNG_ENOTSUP β€” the option opt is not supported.
  • NNG_EREADONLY β€” the option opt is read-only.
  • NNG_ESTATE β€” the socket is in an inappropriate state for setting this option.
bestie, if you're getting NNG_ESTATE, the socket is just not in her era for this. respectfully. πŸ™ˆ

✨ SEE ALSO ✨

nng_ctx_get(3), nng_socket_set(3), nng_strerror(3), nng_ctx(5), nng_options(5), nng_socket(5), nng(7)


and that's the whole page, periodt. πŸ’œ

kisses, this was NNG Reference Manual content, dated 2026-06-30 β€” go forth and set your options, bestie, you've absolutely got this. πŸŽ€βœ¨πŸ‘‘

πŸ“¦ where this page comes from