NNG_BUS(7)
β¨ nng_bus β the bus protocol, aka the group-chat of sockets β¨
okay bestie, gather round, because nng_bus (from the NNG Reference Manual, no less) is literally the mesh-networking protocol and she is everything π
π SYNOPSIS
#include <nng/protocol/bus0/bus.h>
that's it, that's the include, she's lowkey minimal π
π DESCRIPTION
So the bus protocol is how you build mesh networks where every peer is connected to every other peer β like a group chat where everyone has everyone else's number, no cap. In this protocol, every single message a node sends gets sent out to every one of its directly connected peers. iconic behavior, truly. π
Tip π‘ Messages are only sent to directly connected peers. Which means if a peer is only connected indirectly, bestie, she will NOT receive your messages. So when you're building a mesh network with this protocol, it is therefore important that a fully-connected mesh network be constructed. no shortcuts, fr fr.
All message delivery in this pattern is best-effort, which means peers may simply not receive messages. And like, delivery may occur to some, all, or none of the directly connected peers. (Messages are not delivered when peer nodes are unable to receive.) So here's the slay: send operations will never block β instead, if the message can't be delivered for any reason, it just gets discarded. gone. deleted. π
Tip β¨ In order to minimize the likelihood of message loss, this protocol should not be used for high throughput communications. Furthermore, the more traffic in aggregate that occurs across the topology, the more likely that message loss is to occur. it's giving "the vibe gets messy when everyone's talking at once" π
π¦ Socket Operations
The nng_bus0_open() functions create a bus socket. This socket may be used to send and receive messages. Sending messages will attempt to deliver to each directly connected peer β she's doing her best, okay?? π«Ά
πΈ Protocol Versions
Only version 0 of this protocol is supported. (At the time of writing, no other versions of this protocol have been defined.) so version 0 is the main character, periodt. π
π Protocol Options
The bus protocol has no protocol-specific options. that's right, zero, zilch, nothing to configure, we love a low-maintenance queen. β
π Protocol Headers
When using a bus socket in raw mode, received messages will contain the incoming pipe ID as the sole element in the header. π
If a message containing such a header is sent using a raw bus socket, then the message will be delivered to all connected pipes except the one identified in the header. This behavior is intended for use with device configurations consisting of just a single socket. Such configurations are useful in the creation of rebroadcasters, and this capability prevents a message from being routed back to its source. (we do NOT do circular drama here, bestie π)
If no header is present, then a message is sent to all connected pipes.
When using normal (cooked mode) bus sockets, no message headers are present. clean, simple, chef's kiss. β¨
π SEE ALSO
that's the whole page, bestie!! go forth and mesh responsibly ππ¦πΈ
NNG Reference Manual Β· dated 2026-06-30 Β· NNG_BUS(7) β sending u all the love, no packet loss π
π¦ 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