Skip to content
irrld edited this page Aug 4, 2026 · 5 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.

Where to start

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

Reference

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 Rendezvous and hole punching

Requirements

  • C++14 or newer. The default is C++20; -DZNET_CXX_STANDARD=14, 17, 20 or 23 picks 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, so none of them can break your build.

Windows, Linux and macOS.

A note on the examples in this wiki

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.

License

Apache 2.0.

Clone this wiki locally