C++ networking library. This repository contains implementation of platform-independent wrapper on top system TCP & UDP implementation.
- C++17 compatible compiler
- (Optional) Google Test for tests (included as submodule)
- (Optional) Doxygen for API documentation generation
$ git clone https://github.com/foxcpp/wire
$ cd wire
$ mkdir build; cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ cmake --build .
Note 1 By default libwire will be built as a static library, if you want
a shared library then you should add -DBUILD_SHARED_LIBS=ON
flag.
If you use CMake and clone libwire as a submodule, you can just link it this way:
add_subdirectory(wire/)
target_link_library(your-exectuable libwire)
It will use CMake magic to configure include path and other stuff.
Alternatively, you can access system-installed version using find_package
.
find_package(libwire REQUIRED)
target_link_library(your-executable libwire)
Let's write a simple TCP server that echoes back \n
-terminated strings.
First, include TCP listener header:
#include <libwire/tcp/listener.hpp>
Then... It's very short so it doesn't needs any commentary:
using namespace libwire;
tcp::listener listener{ipv4::any, 7};
while (true) {
auto sock = listener.accept();
auto str = sock.read_until<std::string>('\n');
sock.write(str);
}
See examples/ directory for sources and documentation for detailed description.
Maintained in Markdown format (for separate page) and as a docstrings in code (for reference).
Documentation for lastest commit in master is availiable here.
You can also build it locally by running make doc
. Ouput will be placed in doxygen_output/
directory.
Note Undocumented public function which behavior is not obvious is A BUG. Report it!
Here is some of the ways that you can contribute:
- Submit a bug report. We love hearing about broken things, so that we can fix them.
- Provide feedback. Even simple questions about how things work or why they were done a certain way carries value.
- Test code. Checkout
dev
branch, compile it and start trying to break stuff! :-) - Write code. Check issues marked with help wanted tag.
See CODE_STYLE.md and CONTRIBUTING.md for more details.
Distributed under terms of the MIT license. It allows you to do anything with libwire as long as you don't remove any copyright notices. Also, there is no warranties about anything.
See LICENSE.md for details.