|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
This page collects the most common questions developers ask when integrating Network System into their projects. For deeper coverage see the tutorials listed under Tutorial: Choosing the Right Protocol and the Troubleshooting Guide guide.
The facade interfaces report drops through the disconnected callback on clients and the disconnection callback on servers. To recover, register a callback that schedules a retry with exponential backoff:
Always cap the backoff (for example, 30 seconds) and add jitter so a restarted server is not flooded by reconnecting clients. The is_connected() accessor lets you avoid duplicate reconnect attempts when multiple events fire concurrently.
The TCP facade enables TLS via the use_ssl flag plus optional certificate paths.
Important notes:
verify_certificate = false disables certificate verification. Only use it for development against self-signed certificates.unified_messaging_client<protocol::tcp_protocol, tls_policy>) directly.Network System imposes no hard cap. Practical limits come from the operating system file-descriptor budget and the thread pool size you configure on thread_system. On Linux raise the limit with ulimit -n (or LimitNOFILE in systemd units). The library has been tested with tens of thousands of concurrent TCP connections per process.
If you expect very high fan-out, prefer the unified templates with a dedicated thread pool sized to match your CPU core count and use the connection pool API to amortise socket creation.
container_system provides serialisation primitives that pair naturally with network_system. Enable the optional dependency at build time (BUILD_WITH_CONTAINER_SYSTEM=ON, the default), then serialise your container into a byte vector and hand it to client->send(...):
On the receiving side reconstruct the container in the receive callback:
The bridge in BUILD_MESSAGING_BRIDGE glues messaging_system to this serialisation flow when both libraries are linked.
Each facade uses an ASIO io_context driven by a worker thread pool. By default the pool follows thread_system's configuration; you can also attach a custom pool through the unified templates layer.
Key invariants:
start().Most applications never need to touch buffer sizes; the defaults are tuned for high throughput. When you do need to override them:
messaging_client / messaging_server constructors. The facade exposes only the most common knobs; drop down to the unified templates for the full set.Use this short checklist:
http_facade.quic_facade.A more detailed comparison lives in Tutorial: Choosing the Right Protocol.
Several actionable steps:
Release mode (cmake --preset release) to enable optimisations and disable assertions.tcp_facade::create_connection_pool instead of reconnecting per request.network_system benchmarks (NETWORK_BUILD_BENCHMARKS=ON) to baseline your machine.send call. The TCP layer will not combine writes for you.For deeper analysis enable the EventBus metrics and forward them to monitoring_system. The metrics expose connection counts, bytes per second, and pipeline timings.
Every facade method returns either a Result<T> or invokes the error callback. The recovery checklist is:
result.is_err() before assuming a send or receive succeeded.result.error().message (or the std::error_code from the error callback).Avoid swallowing errors silently; the network is the most common source of runtime failures in distributed systems.
Three patterns work well:
127.0.0.1 inside the test. The library is fast enough that thousands of round trips fit in milliseconds. The examples/ directory shows the pattern.i_protocol_client or i_protocol_server can be tested with a hand-written mock that records calls and triggers callbacks synchronously.For long-running soak testing the project provides Google Benchmark suites (NETWORK_BUILD_BENCHMARKS=ON) and load tests (NETWORK_BUILD_INTEGRATION_TESTS=ON).