|
NetCpp
v0.2
|

The C++ standard library is known to be less comprehensive than the libraries traditionally available for other programming languages (e.g., Java, Python, etc.). The C++11 standard began to fill this gap by adding several features like support for multithreading, smart pointers, etc. Incredibly, however, a basic support for networking is still missing.
During the last years, a number of C++ libraries have been proposed to have portable networking in C++, the most important being Boost::asio and cpp-netlib. However, we believe that the syntax of both these libraries is still more complicated than necessary. In particular, we believe that an ideal C++ networking library should be:
NetCpp is a proof of concept to show that such a networking library can be made easily designed in C++. This tiny library has been built after the experience with the OnPosix library. The syntax of the library is straightforward. The modular design given by the adoption of design patterns (i.e., Abstract Factory and Bridge) allows to easily add new protocols and supported platforms.
To build NetCpp you need both:
Currently, only Posix systems (e.g., Linux). However, porting the library to different platforms is very easy thanks to its modular design.
Compile through the following commands:
The library is put in the netcpp/bin/ directory. The include files are available in the netcpp/include/ directory.
Documentation is generated through Doxygen. To generate the documentation, type:
Start reading documentation by opening doc/html/index.html.
Usage of the library is straightforward:
Example of TCP server:
Example of TCP client:
Example of UDP server:
Example of UDP client:
The library has a modular internal design which, thanks to the design patterns used, allows to decouple specific platform-dependent code (which is on the net::AbstractSystemSocket hierarchy) from any protocol design (which is on the net::AbstractSocket hierarchy). Modularity is especially given by the Bridge pattern, which allows two class hierarchies to vary independently.
Thus, to add a new supported platform, you only need to:
The build system, based on cmake, can be easily ported among all supported platforms.
See the following picture to understand the collaboration between classes:
To add a new protocol:
The library is under the Boost license. Read the LICENSE file for more information.
For reporting bugs or proposing new patches, use the issues link of GitHub.