A very basic socket library for C++
SocketPP is a very simple API with TCP and UDP socket implementatins for C++, both for client and server. They are provided by the following classes:
- TCPClientSocket: TCP client socket (demo)
- TCPServerSocket: TCP server socket (demo)
- UDPSocket: UDP socket (client demo and server demo)
Include this in CMakeLists.txt:
include(FetchContent)
FetchContent_Declare(
socketpp
URL https://github.com/mmsobral/socketpp/archive/refs/tags/v1.0.0.tar.gz
)
FetchContent_MakeAvailable(socketpp)
include_directories(${poller_SOURCE_DIR} .)
# OBS: this is just a demo to show you how to link this library to your executable
# The following line is usually generated by CLion (or by yourself, if using cmake manually)
# Replace it accordingly to your project
add_executable(test_app main.cpp)
# This command links socketpp library to your executable
# Rename test_app to yout executable name
target_link_libraries(test_app socketpp)
SocketPP requires at least C++ 2017. To compile an application with SocketPP with g++ or clang, use option -std=c++17. For instance, to compile the UDP client demo with g++ you can execute:
g++ -std=c++17 -o uclient uclient.cpp BaseSocket.cpp UDPSOcket.cpp