|
StormByte C++ Library: Network module 0.0.9999
StormByte-Network is a StormByte library module for handling and create network connections
|
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
The StormByte Network module provides a robust, cross-platform C++ library for building client-server applications. It abstracts away platform-specific socket handling (Linux and Windows) and provides a high-level, type-safe packet-based communication system. The library uses modern C++ features including Expected types for error handling, move semantics, and RAII for resource management.
Expected<T, E> pattern to avoid exceptions in performance-critical pathsThe library is built around three main base classes that you extend to implement your application logic:
Packet** - Base class for all network messages. Each packet has an opcode (message type identifier) and serializes its data.Server / Client** - High-level connection endpoints. Override ProcessClientPacket() in Server or use Send()/Receive() in Client to handle communication.The example below shows the minimal pieces needed with the new API: packet types derived from Transport::Packet, a deserializer function, a small Client helper that uses Send() as a request/response primitive and a Server that replies from ProcessClientPacket().
Explanation:
Packet objects and is passed to both Client and Server constructors.Client::Send() is used as a synchronous request/response helper in this simplified pattern (the test wraps Send into higher-level helpers).Server::ProcessClientPacket() inspects the opcode and can return a PacketPointer to send back immediately (or nullptr when no reply is needed).Contributions are welcome! Please fork the repository and submit pull requests for any enhancements or bug fixes.
This project is licensed under GPL v3 License - see the [LICENSE](LICENSE) file for details.