NNG_PIPE_NOTIFY(3)
π
NNG_PIPE_NOTIFY(3) β the nng_pipe_notify page, bestie edition
okay so first things first: this is a page from the NNG Reference Manual, and we're talking about nng_pipe_notify. Buckle up, it's actually so good. π
β¨ NAME β¨
nng_pipe_notify β register pipe notification callback π (yes that's the whole job, and she does it flawlessly)
πΈ SYNOPSIS πΈ
#include <nng/nng.h>
typedef enum {
NNG_PIPE_EV_ADD_PRE,
NNG_PIPE_EV_ADD_POST,
NNG_PIPE_EV_REM_POST,
} nng_pipe_ev;
typedef void (*nng_pipe_cb)(nng_pipe, nng_pipe_ev, void *);
int nng_pipe_notify(nng_socket s, nng_pipe_ev ev, nng_pipe_cb cb, void *arg);
π¦ DESCRIPTION π¦
So nng_pipe_notify() signs up the callback function cb to get called whenever the pipe event you picked with ev happens on the socket s. And your callback? She gets handed arg as her final argument. So cute. π«Ά
You can have a different callback for each event, slay. But here's the tea: each event can have at most one callback registered. And registering a new one? It implicitly unregisters whatever was registered before. One in, one out. Periodt. π
Here are the pipe events that are supported:
NNG_PIPE_EV_ADD_PREβ this one fires after a connection and negotiation have both completed, but before the pipe gets added to the socket. And listen: if you close the pipe here (withnng_pipe_close()), the socket will never see that pipe, and no further events will happen for that pipe. Gone. Girlboss move, honestly.NNG_PIPE_EV_ADD_POSTβ this fires after the pipe is fully added to the socket. And real talk: before this moment, it is not possible to communicate over the pipe with the socket. So don't even try it. πNNG_PIPE_EV_REM_POSTβ this fires after the pipe has been removed from the socket. The underlying transport may be closed at this point, and it is not possible to communicate using this pipe. It's over, it's giving ex-pipe. π
Warning π¨π¨ The callback cb function must not attempt to perform any accesses to the socket, because it is called with a lock on the socket held! Doing so would thus result in a deadlock. Like literally do not. You will freeze forever. The worst vibe imaginable. π
Tip β¨ The callbackcbmay close a pipe for any reason by simply closing it usingnng_pipe_close(). This might be done before the pipe is added to the socket (duringNNG_PIPE_EV_ADD_PRE), for example, if the remote peer is not authorized. Kick them out, respectfully. πͺπ
Tip π It is totally possible to register the samecbandargfor different events β just call this function separately for the different values ofev. Recycling is iconic. π§
Note π This function ignores invalid values for ev. Not mad, just ignoring you.
β RETURN VALUES β
This function returns 0 on success, and non-zero otherwise. That's it, that's the whole scale. No in-between, no "it's complicated." πΈ
π ERRORS π
NNG_ECLOSEDβ the socketsdoes not refer to an open socket. She's closed, bestie, there's nothing to talk to. π
π SEE ALSO π
nng_pipe_close(3), nng_pipe_getopt(3), nng_pipe(5), nng_socket(5), nng(7)
and that's the whole page!! π source/version is NNG Reference Manual, dated 2026-06-30, footer still says NNG_PIPE_NOTIFY(3) which is so on brand. go forth and notify your pipes, bestie. no cap. π¦β¨π
π¦ 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