NNG_CTX_SETOPT(3)

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

✨ nng_ctx_setopt ✨ (from the NNG Reference Manual, bestie πŸ’–)

okay so this is nng_ctx_setopt from the NNG Reference Manual β€” it's the girl whose whole job is sliding options onto your context. sit down, hydrate, let's go 🫢

🌸 NAME 🌸

nng_ctx_setopt β€” set context option. that's it. that's the girl. she sets. the option. periodt πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <nng/nng.h>

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

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

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

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

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

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

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

like, seven whole forms. she's got range πŸ’œ


πŸ‘‘ DESCRIPTION πŸ‘‘

⚠️ Important β€” these functions are deprecated. please look at nng_ctx_set instead. and ngl they might not even be here if the library was built with NNG_ELIDE_DEPRECATED. so if she ghosted you, that's why 😭

the nng_ctx_setopt() functions configure options for the context ctx. the actual options you can configure this way vary, and they're specified by opt.

πŸ’¬ Note β€” context options are protocol specific. the details get documented with the protocol itself. iykyk.

🌈 Forms 🌈

the type, size, and semantics of an option all depend on the actual option β€” and all of that is documented with the option itself. so like, go read the option's own page, bestie, she has lore.

  • nng_ctx_setopt() β€” untyped and unbothered. she can configure any arbitrary data. the val pointer addresses the data to copy, and valsz is the size of the object located at val.
πŸ’‘ Tip β€” it might be easier to just use one of the typed forms below. no cap.
  • nng_ctx_setopt_bool() β€” for options that take a Boolean (bool). the bval gets passed to the option. true/false energy ✨
  • nng_ctx_setopt_int() β€” for options that take an integer (int). the ival is passed to the option.
  • nng_ctx_setopt_ms() β€” for configuring time durations (timeouts, etc.) using type nng_duration. the duration dur is an integer number of milliseconds.
  • nng_ctx_setopt_size() β€” for configuring a size, z. typically buffer sizes, message maximum sizes, and similar options.
  • nng_ctx_setopt_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 as well β€” check the documentation for each option for details. she's picky and that's valid.)
  • nng_ctx_setopt_uint64() β€” for configuring a 64-bit unsigned value, u64. typically options related to identifiers, network numbers, and similar.

πŸ’– RETURN VALUES πŸ’–

these functions return 0 on success, and non-zero otherwise. that's the whole vibe check.


πŸ’€ ERRORS πŸ’€

  • NNG_ECLOSED β€” parameter s does not refer to an open socket. (yes the original says s. we don't question the queen's naming choices πŸ™ˆ)
  • NNG_EINVAL β€” the value being passed is invalid. she said no.
  • NNG_ENOTSUP β€” the option opt is not supported. not on the menu, babe.
  • NNG_EREADONLY β€” the option opt is read-only. eyes only. no touching.
  • NNG_ESTATE β€” the socket is in an inappropriate state for setting this option. wrong place, wrong time, iconic behavior honestly 😭

πŸ”₯ SEE ALSO πŸ”₯

go read those too, they're all main characters πŸŽ€


and that's the page!! this whole thing is from the NNG Reference Manual, dated 2026-06-30 β€” love her, stan her, cite her properly πŸ’…πŸŒΈ stay hydrated and remember: check your return values, bestie πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from