NNG_SOCKET(5)
β¨ NAME β¨
nng_socket β the socket handle, aka ur main character π
π¦ SYNOPSIS π¦
#include <nng/nng.h>
typedef struct nng_socket_s nng_socket;
π DESCRIPTION π
okay so bestie, an nng_socket is literally just a handle to an underlying socket object. that's it, that's the vibe. every single bit of communication between ur app and ur remote Scalability Protocol peers happens through sockets. no socket, no chat. π
a given socket can have multiple dialers (nng_dialer) and/or listeners (nng_listener), plus multiple pipes (nng_pipe), and it can be connected to multiple transports at the same time. multitasking queen π
BUT β and this is the important part β a given socket will have exactly one protocol associated with it, and it's responsible for any state machines or other protocol-specific logic. one socket, one protocol, no exceptions. periodt.
Important π¨ the nng_socket structure is always passed by value (both for input parameters and return values), and should be treated opaquely. passing structures this way gives the compiler a chance to perform accurate type checks in functions passing values of this type. so like. don't go poking at its insides, it's giving "look but don't touch" energy. the compiler is the bouncer at the door and it will check ur type. π
each nng_socket is created by a protocol-specific constructor, such as nng_rep_open(). and when ur done with the socket, when it's served its purpose and ate and left no crumbs, u close it with nng_close(). π«Ά
πΈ Initialization πΈ
before a socket is opened, u can initialize it using the macro NNG_SOCKET_INITIALIZER β that way u don't get it confused with a valid open socket. it's the "not yet, bestie" state. β¨
for example:
nng_socket s = NNG_SOCKET_INITIALIZER;
boom. initialized. iconic. π
π SEE ALSO π
libnng(3)nng_close(3)nng_getopt(3)nng_setopt(3)nng_socket_id(3)nng_dialer(5)nng_listener(5)nng_options(5)nng(7)
and that's the whole page bestie, no cap β this was the NNG Reference Manual, dated 2026-06-30. go forth and slay ur sockets πβ¨π¦
π¦ 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