simple-socket is a lightweight C++17 based wrapper around POSIX socket APIs. It keeps the native socket model visible while providing RAII ownership, error handling, poll and convenience functions. The API uses strings for IPv4/6 addresses and keeps pointer handling to a minimum. Blocking socket operations have variants accepting a timeout. Functions for DNS resolution and limited network interface management are included.
Clone the repository and build it using CMake:
$ git clone https://github.com/bernhardHartleb/simple-socket.git
$ cd simple-socket
$ cmake -B build
$ cmake --build build
Usage examples are included in the examples directory.
For the complete API and available classes, see the interface documentation.
To use the library in your own project, it is easiest to add this in your CMakeLists.txt:
add_subdirectory(external/simple-socket)
simple-socket uses CMake and includes several unit tests and example programs. There are no external dependencies. The library targets Linux and requires C++17 compiler support; SocketCAN and SCTP support are optional. Source code is released under the MIT License.