-
Notifications
You must be signed in to change notification settings - Fork 5
Home
irrld edited this page Sep 4, 2026
·
7 revisions
A C++ networking library for applications that send structured messages: define a packet, register a serializer, send it. Encryption, compression and framing are handled underneath, and the same API runs over ZDT, znet's reliable-UDP transport, or over TCP. ZDT is the default.
It sits above asio and libuv rather than beside them. Those give you a socket and an event loop; znet gives you sessions, typed messages and an event callback, and owns the threads that drive them.
- Typed packets: derive from
Packet, register a serializer, and a handler receives them already decoded. - AES-256-GCM and zstd, both negotiated during the handshake and both on by default.
- Two transports: ZDT, with 256 channels and per-message reliability and ordering, and TCP, which also carries Unix domain sockets on POSIX.
- Admission control on a listener: CIDR allowlists and denylists, a per-source attempt rate, and a connection cap.
- Keepalives and an idle timeout on both transports.
- Per-session and per-server counters, compiled out entirely at
-DZNET_ENABLE_METRICS=OFF. - NAT traversal in steps: gathering, a rendezvous server, hole punching on one shared socket for a mesh, and a relay for the peers that cannot punch.
- Protocol version negotiation on the ZDT handshake, refusing a mismatch rather than guessing.
| Getting Started | Build it, then a server and a client that talk to each other |
| Packets and Serialization | Defining messages and putting them on the wire |
| Events | Every event, and what you are expected to do in each |
| Session State | Attaching your own per-connection object to a session |
| Choosing a Transport | ZDT or TCP, and ZDT's per-message delivery modes |
| Threading Model | Which thread calls your code, and what is safe to call back |
| Configuration Reference | Every option, what it bounds, and when to change it |
| Encryption and Compression | How both are negotiated, and who decides |
| Metrics | The counters, and reading them without lying to yourself |
| Extensions | Optional add-ons: smaller packets, automatic serialization, engine types on the wire |
| Peer-to-Peer | Gathering, rendezvous, hole punching and the relay fallback |
| API Stability | Which parts may change, and how much notice you get |
-
C++14 or newer. The default is C++20;
-DZNET_CXX_STANDARD=14,17,20or23picks one. Raising it adds capability, never API: the same code compiles at every level. - CMake 3.29+
- OpenSSL, found automatically if installed
-
zstd, bundled, or supply your own with
-DZNET_USE_EXTERNAL_ZSTD=ON - Nothing else. The extensions carry their own dependencies and skip themselves when one is missing, or when the tree is below the standard they need, so none of them can break your build.
Windows, Linux and macOS.
Every code block here is compiled from a real source file as part of writing
these pages, at C++14 through C++23 with -pedantic-errors. Where something is
only available at a higher standard, the page says so.
Apache 2.0.