High-performance peer-to-peer & edge networking module for Vix.cpp.
Designed for offline-first systems, unstable networks, and secure distributed runtimes.
This module powers Vixβs sync engine (WAL / outbox) and forms the transport backbone of the ecosystem.
β
TCP peer connections
β
Secure handshake lifecycle
β
Per-peer session state
β
Peer discovery (UDP broadcast / multicast)
β
HTTP bootstrap (registry pull / announce)
β
Runtime peer & handshake statistics
β
Clean shutdown & signal handling
β
Modular, production-shaped architecture
This is not a toy P2P example.
modules/p2p/
βββ include/ # Public P2P API (Node, Peer, Protocol, Crypto, β¦)
βββ src/ # Implementation
βββ tests/
β βββ manual/ # Manual integration tests
β β βββ main.cpp # p2p_demo (real runtime demo)
β β βββ registry.py # HTTP bootstrap registry (test server)
β βββ CMakeLists.txt
βββ build/ # Build output
β βββ tests/
β βββ p2p_demo # Compiled demo binary
βββ CMakeLists.txt
βββ README.md
βββ CHANGELOG.md
βββ LICENSE
The real executable demo lives here after build:
cmake -S . -B build -DVIX_P2P_BUILD_TESTS=ON
cmake --build build -j
build/tests/p2p_demoIt spins up a full P2P node with:
- listening socket
- optional outbound connections
- discovery
- bootstrap
- live stats
./build/tests/p2p_demo --id A --listen 9001./build/tests/p2p_demo --id B --listen 9002 --connect 127.0.0.1:9001./build/tests/p2p_demo \
--id B \
--listen 9002 \
--connect 127.0.0.1:9001 \
--connect-delay 8000./build/tests/p2p_demo --id A --listen 9001 --run 20Printed periodically while running:
peers_total=2
peers_connected=1
handshakes_started=1
handshakes_completed=1
Final stats are always printed on exit.
--discovery on
--disc-mode broadcast | multicast
--disc-port 37020--bootstrap on
--registry http://127.0.0.1:8080/p2p/v1
--announce onA minimal test registry is provided in:
tests/manual/registry.py
- Explicit handshake state machine
- Per-peer session lifecycle
- Control messages remain plaintext (safe bootstrapping)
- Designed for AEAD encrypted payloads
- Ready for secure WAL / sync traffic
- C++ backend engineers
- Distributed systems developers
- Offline-first / local-first builders
- Edge & P2P networking enthusiasts
- Anyone who wants real P2P, not fake examples
- Clean production-oriented P2P design
- Minimal but realistic
- Built for unstable networks
- Reusable as a base for:
- sync engines
- mesh networks
- decentralized runtimes
- Actively used inside Vix.cpp
βοΈ Actively developed
βοΈ Manually tested
βοΈ Used internally
π§ Continuously evolving
If this module helped you understand how real P2P in C++ should look,
leave a β it genuinely helps the project grow.