https://github.com/dvsku/libnetwrk
Cross-platform networking library.
https://github.com/dvsku/libnetwrk
cpp cpp20 cross-platform dvsku dvsku-libnetwrk libnetwrk networking networking-library
Last synced: 5 months ago
JSON representation
Cross-platform networking library.
- Host: GitHub
- URL: https://github.com/dvsku/libnetwrk
- Owner: dvsku
- License: apache-2.0
- Created: 2023-03-10T04:38:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-19T13:20:50.000Z (about 2 years ago)
- Last Synced: 2024-05-19T14:32:15.054Z (about 2 years ago)
- Topics: cpp, cpp20, cross-platform, dvsku, dvsku-libnetwrk, libnetwrk, networking, networking-library
- Language: C++
- Homepage:
- Size: 1.89 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
libnetwrk
Header-only cross-platform networking library.
## About
Based on javidx9's work with networking.
Recommended for use on small personal projects as it's not heavily tested.
## Dependencies
- ASIO 1.30.2 (embedded)
## Requirements
- c++20
- compiler support for concepts and coroutines
## Tested compiler support
- MSVC 14.30 / Visual Studio 2022 17.0
- GCC 10.5 with -fconcepts and -fcoroutines
## Usage
### CMake
libnetwrk TARGET is provided as an INTERFACE that sets up compile flags, definitions and include directories.
- Add libnetwrk via ``ADD_SUBDIRECTORY`` or ``FetchContent``
- Use ``LINK_LIBRARIES(libnetwrk)`` or ``TARGET_LINK_LIBRARIES(your_target PRIVATE|PUBLIC libnetwrk)``
- Include ``libnetwrk.hpp``
### Manual
...
## Limitations
- currently only supports TCP
- ``std::size_t`` clamped to ``uint32_t`` to enable architecture independent serialization/deserialization of STL containers
## Usage examples
### Making a custom object serializeable
```
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;
}
}
```