Based on javidx9's work with networking.
Recommended for use on small personal projects as it's not heavily tested.
- ASIO 1.30.2 (embedded)
- c++20
- compiler support for concepts and coroutines
- MSVC 14.30 / Visual Studio 2022 17.0
- GCC 10.5 with -fconcepts and -fcoroutines
libnetwrk TARGET is provided as an INTERFACE that sets up compile flags, definitions and include directories.
- Add libnetwrk via
ADD_SUBDIRECTORY
orFetchContent
- Use
LINK_LIBRARIES(libnetwrk)
orTARGET_LINK_LIBRARIES(your_target PRIVATE|PUBLIC libnetwrk)
- Include
libnetwrk.hpp
...
- currently only supports TCP
std::size_t
clamped touint32_t
to enable architecture independent serialization/deserialization of STL containers
void serialize(libnetwrk::dynamic_buffer& buffer) const {
...
}
void deserialize(libnetwrk::dynamic_buffer& buffer) {
...
}
To make an object serializable you need to add and implement these functions.
#include "libnetwrk.hpp"
struct object {
std::string string_1;
void serialize(libnetwrk::dynamic_buffer& buffer) const {
buffer << string_1;
}
void deserialize(libnetwrk::dynamic_buffer& buffer) {
buffer >> string_1;
}
}
struct derived_object : object {
std::string string_2;
void serialize(libnetwrk::dynamic_buffer& buffer) const {
object::serialize(buffer);
buffer << string_2;
}
void deserialize(libnetwrk::dynamic_buffer& buffer) {
object::deserialize(buffer);
buffer >> string_2;
}
}