NNG_PUSH(7)

πŸ“¦
version 1.12.0 Β· 4 versions
, in ubuntu stonking

✨ NNG_PUSH ✨

okay bestie, gather round, because today we're talking about nng_push β€” the push protocol from the NNG Reference Manual, and honestly? she's giving load balancer energy and I'm obsessed πŸ’…


🌸 SYNOPSIS 🌸

#include <nng/protocol/pipeline0/push.h>

πŸ’– DESCRIPTION πŸ’–

So the push protocol is literally one half of the pipeline pattern β€” and the other half? That's the pull protocol, her other half, her soulmate, her nng_pull(7). 🫢

Here's the vibe: in the pipeline pattern, pushers distribute messages to pullers. Every single message a pusher sends gets handed off to one of its peer pullers, and the way it picks is round-robin β€” like okay we're going down the list, everyone gets a turn, no favorites πŸ’… β€” chosen from the set of connected peers that are actually available to receive. That little property right there is what makes this pattern so good at load-balancing scenarios. Lowkey iconic. πŸ‘‘

πŸŽ€ Socket Operations πŸŽ€

The nng_push0_open() call creates a pusher socket. This socket is a sender, periodt β€” it can send messages, but she cannot receive them, sorry. If you try to receive on her, you get NNG_ENOTSUP, and that's just the rules bestie 😭

Send operations observe flow control (aka back-pressure, the group-chat "hold on I'm typing" of networking), so only peers that are actually capable of accepting a message get considered. And if literally no peer is available to receive your message? Then the send operation just waits until one shows up, or until the operation times out. No message gets yeeted into the void on purpose. ✨

Note πŸ“Œ Even though the pipeline protocol honors flow control and genuinely tries to avoid dropping messages, there is no guarantee of delivery. No cap. And because there's no capability for message acknowledgment at all, if your app actually needs reliable delivery, you're encouraged to consider the req protocol instead β€” that's nng_req(7), she's built different. πŸ’€

πŸ¦‹ Protocol Versions πŸ¦‹

Only version 0 of this protocol is supported. And at the time of writing, no other versions of this protocol have even been defined, so like… there's nothing else to support. That's the whole list. 🌈

🌷 Protocol Options 🌷

  • NNG_OPT_SENDBUF β€” (int, 0 - 8192). Normally you set this to zero, which means send operations are unbuffered. In unbuffered mode, send operations just wait until a suitable peer is available to receive the message. If you set it to a positive value (up to 8192), then an intermediate buffer gets provided for the socket with that specified depth in messages. Your call, bestie πŸŽ€
Note πŸ“Œ Transport layer buffering may happen in addition to whatever socket buffer you set with this option. So don't come for me when there's more buffering than you asked for β€” it's not the socket's fault, there are layers here. πŸ™ˆ

🧚 Protocol Headers 🧚

The push protocol has no protocol-specific headers. Nothing. Clean. Minimalist. She said "I don't need accessories, I'm the accessory." πŸ’…βœ¨


πŸ‘‘ SEE ALSO πŸ‘‘


okay and one last thing before you go β€” this whole page is from the NNG Reference Manual, dated 2026-06-30 πŸ’– so if you're citing her, tag her properly. mwah, go forth and round-robin responsibly, bestie 🫢🌸

πŸ“¦ where this page comes from