NNG_STREAM_GET(3str)
π NAME π
okay so bestie, this is nng_stream_get(3str) β the nng_stream_get family is literally here to get an option from a byte stream. π
β¨
π SYNOPSIS π
#include <nng/nng.h>
int nng_stream_get(nng_stream *s, const char *opt, void *val, size_t *sizep);
int nng_stream_get_bool(nng_stream *s, const char *opt, bool *valp);
int nng_stream_get_int(nng_stream *s, const char *opt, int *valp);
int nng_stream_get_ms(nng_stream *s, const char *opt, nng_duration *valp);
int nng_stream_get_ptr(nng_stream *s, const char *opt, void **valp);
int nng_stream_get_size(nng_stream *s, const char *opt, size_t *valp);
int nng_stream_get_addr(nng_stream *s, const char *opt, nng_sockaddr *valp);
int nng_stream_get_string(nng_stream *s, const char *opt, char **valp);
int nng_stream_get_uint64(nng_stream *s, const char *opt, uint64_t *valp);
π¦ DESCRIPTION π¦
the nng_stream_get() functions retrieve option values for the byte stream conn. π«Ά
The actual options you can retrieve this way vary. A number of them are documented in nng_options(5) and in additional linked documents. iykyk. π«
πΈ Forms πΈ
In all of these forms, the option opt is retrieved from the connected byte stream s. The forms differ based on the type of option they take. The details of the type, size, and semantics of the option depend on the actual option, and are documented with the option itself. no cap. β¨
nng_stream_get()β this one is untyped and can retrieve the value of any option. The caller must store a pointer to a buffer to receive the value inval, and the size of the buffer shall be stored at the location referenced bysizep. When the function returns, the actual size of the data copied (or that would have been copied if sufficient space were present) is stored at the location referenced bysizep. If the callerβs buffer is not large enough to hold the entire object, then the copy is truncated. Therefore the caller should check for truncation by verifying that the returned size insizepdoes not exceed the original buffer size. It is acceptable to passNULLforvalif the value insizepis zero. This can be used to determine the size of the buffer needed to receive the object. π
π‘ Tip: it may be easier to use one of the typed forms of this function. bestie behavior, honestly.
nng_stream_get_bool()β this function is for options which take a Boolean (bool). πnng_stream_get_int()β this function is for options which take an integer (int). βnng_stream_get_ms()β this function retrieves time durations (such as timeouts), stored as a number of milliseconds. The special valueNNG_DURATION_INFINITEmeans an infinite amount of time, and the special valueNNG_DURATION_DEFAULTmeans a context-specific default. time stuff, iconic. β³nng_stream_get_ptr()β this function retrieves a pointer to structured data. The data referenced is generally managed using other functions. Note that this form is somewhat special in that the object is generally not copied, but instead the pointer to the object is copied. π
π Note: care must be taken to ensure that the application respects any considerations about the lifetime of the underlying object. See the documentation for the option for more specific guidance. lowkey important, donβt fumble it. π«Ά
nng_stream_get_size()β this function retrieves a size, typically for buffer sizes, message maximum sizes, and similar options. πnng_stream_get_addr()β this function retrieves a socket address. πnng_stream_get_string()β this function retrieves aNULL-terminated string. This string is created from the source usingnng_strdup()and consequently must be freed by the caller usingnng_strfree()when it is no longer needed. slay, but free it. π§nng_stream_get_uint64()β this function retrieves a 64-bit unsigned value. This is typically used for identifiers, network numbers, and similar options. π
π RETURN VALUES π
This function returns 0 on success, and non-zero otherwise. thatβs the whole vibe check. β¨
π ERRORS π
NNG_ECLOSEDβ the connection is closed. πNNG_EINVALβ there was insufficient space to receive the object. The amount of data actually needed is returned insizep. check the size, bestie. πNNG_ENOTSUPβ the option is not supported. πNNG_EWRITEONLYβ the option may not read. π
π₯ SEE ALSO π₯
nng_strerror(3)nng_stream_set(3str)nng_options(5)nng_ipc_options(5)nng_tcp_options(5)nng_tls_options(5)nng_stream(5)
thatβs the whole page, bestie π with love from the NNG Reference Manual, dated 2026-01-13 πβ¨
π¦ 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