NNG_STREAM_SET(3str)
π NNG_STREAM_SET(3str) β¨
okay bestie, welcome to the NNG Reference Manual β stream edition. this is the 3str page, aka the one where we dial in all the little settings on a byte stream. buckle up π
π SYNOPSIS
like, here's everything you can call. copy-paste city:
#include <nng/nng.h>
int nng_stream_set(nng_stream *s, const char *name, const void *data, size_t size);
int nng_stream_set_bool(nng_stream *s, const char *opt, bool val);
int nng_stream_set_int(nng_stream *s, const char *opt, int val);
int nng_stream_set_ms(nng_stream *s, const char *opt, nng_duration val);
int nng_stream_set_ptr(nng_stream *s, const char *opt, void *val);
int nng_stream_set_size(nng_stream *s, const char *opt, size_t val);
int nng_stream_set_string(nng_stream *s, const char *opt, const char *val);
int nng_stream_set_uint64(nng_stream *s, const char *opt, uint64_t val);
int nng_stream_set_addr(nng_stream *s, const char *opt, const nng_sockaddr *val);
πΈ DESCRIPTION
so the nng_stream_set() functions are literally how you configure options for the byte stream s. which options can you set this way? it varies, babe β that's what opt tells you. a bunch of them are documented over in nng_options(5).
and on top of that, some transport-specific and protocol-specific options are documented with the transports and protocols themselves. iykyk π¦
π§ Forms
the tea on the type, size, and semantics of each option depends on the actual option, and gets documented with the option itself. but here's the rundown of the forms:
nng_stream_set()β this one is untyped, so it can configure literally any arbitrary data. thevalpointer addresses the data to copy, andsizeis the size of the object located atval.
β οΈ Note: this function is deprecated. callers should use one of the typed functions instead. no cap, use the typed ones π
nng_stream_set_bool()β for options that take a Boolean (bool).nng_stream_set_int()β for options that take an integer (int).nng_stream_set_ms()β configure time durations (like timeouts) using the typenng_duration. the duration is an integer number of milliseconds.nng_stream_set_ptr()β passes a pointer to structured data. the data referenced is generally managed by other functions. for example, TLS configuration objects created withnng_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. pls see the documentation for the specific option for further details.
nng_stream_set_size()β configure a size, typically for buffer sizes, message maximum sizes, and similar options.nng_stream_set_string()β configure a string. 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.) β¨nng_stream_set_uint64()β configure a 64-bit unsigned value. this is typically used for identifiers, network numbers, and similar options.nng_stream_set_addr()β bestieβ¦ this one performs no useful function, and will be removed in a future release. π like, it's giving deprecated-but-not-even-labeled. just don't.
π RETURN VALUES
this function returns 0 on success, and non-zero otherwise. simple as that π
π ERRORS
NNG_ECLOSEDβ the connection is closed. πNNG_EINVALβ eitherdataorsizeare invalid. πNNG_ENOTSUPβ the option is not supported. nope, not today.NNG_EREADONLYβ the option may not be modified. hands off, it's read-only π₯
π SEE ALSO
nng_strerror(3), nng_stream_get(3str), nng_options(5), nng_ipc_options(5), nng_tcp_options(5), nng_tls_options(5), nng_stream(5)
okay that's the whole vibe check π¦ this page is from the NNG Reference Manual, dated 2026-01-13, and it lives at NNG_STREAM_SET(3str) β go set some options, bestie, you got this πβ¨
π¦ where this page comes from
- alpine 3.24: nng-doc 1.11-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms