Netlib
C++ wrapper for the linux c-network interface
|
This project provides a simple c++ wrapper around the annoying unix-c network functions. The focus lies especially on removing the need to work with the sockaddr
, sockaddr_in
and sockaddr_in6
structs directly.
This is done by the classes IpAddr
and SockAddr
that hide all the low level structs and the evil type punning, as well as the network byte order and raw address / string conversions.
Instead Ip-Addresses are simply specified as string
and ports as uint16_t
(in host byte order). All the conversions and Ipv4/Ipv6 differences are handled behind the scenes.
Doxygen documentation of the public API is available on gitlab-pages.
Some examples using the library are available in the example
subdirectory.
This library can be used in many different ways. The most simple of which would be to just copy the content of the src
directory in another project. The better way would be to include it in the buildsystem used by the other project. The provided Makefile
compiles this library to a static library that can be statically linked.
mkdir libs
cd libs
git submodule add https://code.fbi.h-da.de/istddmue2/netlib.git
CMakeLists.txt
to include the library