NNG_SOCKET_SET(3)
π nng_socket_set β set socket option π
okay so bestie, welcome to the NNG Reference Manual, page nng_socket_set(3) β yes that's the one, we're doing this π
β¨ SYNOPSIS β¨
#include <nng/nng.h>
int nng_socket_set(nng_socket s, const char *opt, const void *val, size_t valsz);
int nng_socket_set_bool(nng_socket s, const char *opt, bool bval);
int nng_socket_set_int(nng_socket s, const char *opt, int ival);
int nng_socket_set_ms(nng_socket s, const char *opt, nng_duration dur);
int nng_socket_set_ptr(nng_socket s, const char *opt, void *ptr);
int nng_socket_set_size(nng_socket s, const char *opt, size_t z);
int nng_socket_set_string(nng_socket s, const char *opt, const char *str);
int nng_socket_set_uint64(nng_socket s, const char *opt, uint64_t u64);
πΈ DESCRIPTION πΈ
The nng_socket_set() functions are how you configure options on the socket s, bestie. Which options you can actually set this way? Depends!! It's all decided by opt, and a whole bunch of them are documented over in nng_options(5) π
Protocol-specific options get documented with the protocol in question, so check there for those ones.
Important π¨ Access to transport options through this function is deprecated, and it may be removed from a future release. Instead, applications should usenng_dialer_getornng_listener_getfor specific dialers or listeners. So likeβ¦ use the new ones, okay? π«Ά
π¦ Forms π¦
The type, size, and semantics of the option all depend on the actual option you're setting, and they're documented with that option itself, so no guessing π
nng_socket_set()β this one is untyped and can be used to configure literally any arbitrary data. Thevalpointer addresses the data to copy, andvalszis the size of the object located atval.
Tip β¨ It may be easier to use one of the typed forms of this function. fr fr.
nng_socket_set_bool()β for options that take a Boolean (bool). Thebvalis passed to the option.nng_socket_set_int()β for options that take an integer (int). Theivalis passed to the option.nng_socket_set_ms()β this is the one for configuring time durations (timeouts and friends) using typenng_duration. The durationduris an integer number of milliseconds, periodt.nng_socket_set_ptr()β passes a pointer,ptr, to structured data. The data referenced byptris generally managed by other functions. Like, for example, TLS configuration objects created with (nng_tls_config_alloc()) can be passed this way π
Note This form is kinda special β the object is generally not copied, instead the pointer to the object is copied. iykyk π
nng_socket_set_size()β configures a size,z. Typically for buffer sizes, message maximum sizes, and similar options πnng_socket_set_string()β configures a string,str. Strings passed this way must be legal UTF-8 or ASCII strings, terminated with aNUL(\0) byte. (Other constraints may apply too β see the documentation for each option for details, bestie.)nng_socket_set_uint64()β configures a 64-bit unsigned value,u64. Typically used for options related to identifiers, network numbers, and similar π’
π RETURN VALUES π
These functions return 0 on success, and non-zero otherwise. slay β¨
π ERRORS π
NNG_ECLOSEDβ parametersdoes not refer to an open socket. πNNG_EINVALβ the value being passed is invalid.NNG_ENOTSUPβ the optionoptis not supported.NNG_EREADONLYβ the optionoptis read-only. sad πNNG_ESTATEβ the socket is in an inappropriate state for setting this option.
π«Ά SEE ALSO π«Ά
nng_socket_get(3), nng_dialer_set(3), nng_listener_set(3), nng_strerror(3), nng_options(5), nng_socket(5), nng(7)
okay that's the whole page bestie, you ate that π this was NNG_SOCKET_SET(3) from the NNG Reference Manual, dated 2026-06-30 β go set some options, main character πβ¨π
π¦ 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