You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Easy to use, low invasiveness, full platform support, does not require forcible installation into the system's include directory, recommended to be directly referenced as a submodule or used directly with static libraries
Built with modern C++, similar in usage and functions to Go's gin framework, small learning and entry cost, suitable for beginners to learn source code
Lightweight framework, very small, with less than 5000 lines of source code, avoiding the bloat of large network frameworks
The website's documentation system and testing framework ensure usability and stability.
Quick Start
Using the Release Package
Download the release library (Releases · chenxuan520/cppnet), and extract it (you can choose any location, you can put it in the system's include directory or not. In the following, it is assumed that the extraction is to the current directory). A C++17-compatible compiler is required.
If you need SSL (you need to install OpenSSL), download the SSL version. The default option is fine.
Write code. You can write code according to your needs. The following are two simple demos, one without SSL and the other with SSL. For specific function descriptions, you can refer to the documentation.
If you are using CMake to compile, you need to add the following content to the CMakeLists.txt file. In fact, you just add the link library
# Whether to use SSL or not, you need to add thislink_directories(./cppnet/lib)
link_libraries(-lcppnet)
# **If you are using the SSL version and need to use the SSL function, you need to add the following**add_definitions(-DCPPNET_OPENSSL)
link_libraries(-lssl-lcrypto)
If you are using Makefile to compile, you need to add -L./cppnet/lib and -lcppnet to the compilation options. Here is a Makefile compilation demo. Of course, if it is an SSL compilation, you also need to add the lib library and add the CPPNET_OPENSSL macro.
Execute the compilation to obtain the compiled file successfully.
Compiling from source
Use git clone https://github.com/chenxuan520/cppnet --recurse-submodules to pull the source code
By default, the ssh version is compiled. If you need an ssl-free version, you need to modify the cmake file manually
Run cd src;./build.sh to generate the static library in lib
Requires cmake
Requires a compiler that supports C++17
Performance Testing
Automated testing is performed using ubuntu-latest from github action, with machine configuration refer to
4 cores, 16GB of memory, and 14GB of hard disk
Automatically run updated test results based on each commit's code, referring to the scripts in the bench folder, and the hash value will also be in the picture.
Use vegeta for stress testing, testing at different QPS respectively
Average response time
p99 response time
Accuracy
Wait time
Compare cppnet framework and go gin framework, and implement the same function with both
More Demo
More demo references can be found in the "demo" folder and the "test" folder.