Skip to the content.

🏠 Home | Next: Basic Usage >


Getting Started

To use cpp-tcpnet, include the cpptcpnet.hpp header in your project. It also depends on cpp-pubsub and cpp-asyncworker.

Integration

You can have CMake automatically download and integrate cpp-tcpnet and its dependencies. By default, it downloads and compiles LibreSSL from source to provide out-of-the-box SSL/TLS support.

The following CMake options can be configured before including cpp-tcpnet:

include(FetchContent)

# Optional configuration overrides:
# set(CPPTCPNET_USE_LIBRESSL OFF CACHE BOOL "Use system OpenSSL")
# set(CPPTCPNET_LIBRESSL_VERSION "3.9.2" CACHE STRING "LibreSSL version")
# set(CPPTCPNET_ENABLE_SSL OFF CACHE BOOL "Enable SSL support")

FetchContent_Declare(
  cpptcpnet
  GIT_REPOSITORY https://github.com/jonoton/cpp-tcpnet.git
  GIT_TAG main
)
FetchContent_MakeAvailable(cpptcpnet)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE cpptcpnet::cpptcpnet)

2. Manual Compilation (Without CMake)

If you are compiling manually without CMake, you will need:

# Compiling with SSL/TLS support:
g++ -std=c++17 -pthread -DCPPTCPNET_SSL_SUPPORT -I/path/to/cpp-pubsub -I/path/to/cpp-asyncworker main.cpp -lssl -lcrypto -o my_app

# Compiling without SSL/TLS support:
g++ -std=c++17 -pthread -I/path/to/cpp-pubsub -I/path/to/cpp-asyncworker main.cpp -o my_app

🏠 Home | Next: Basic Usage >