NNG_STREAM_SET(3str)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… 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. the val pointer addresses the data to copy, and size is the size of the object located at val.
⚠️ 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 type nng_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 with nng_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 a NUL (\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 β€” either data or size are 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