NNG_CTX_SETOPT(3)
β¨ 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 atnng_ctx_setinstead. and ngl they might not even be here if the library was built withNNG_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. thevalpointer addresses the data to copy, andvalszis the size of the object located atval.
π‘ 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). thebvalgets passed to the option. true/false energy β¨nng_ctx_setopt_int()β for options that take an integer (int). theivalis passed to the option.nng_ctx_setopt_ms()β for configuring time durations (timeouts, etc.) using typenng_duration. the durationduris 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 aNUL(\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β parametersdoes not refer to an open socket. (yes the original sayss. we don't question the queen's naming choices π)NNG_EINVALβ the value being passed is invalid. she said no.NNG_ENOTSUPβ the optionoptis not supported. not on the menu, babe.NNG_EREADONLYβ the optionoptis 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
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms