This repository contains header-only C++ classes and example code for using sockets on Linux and Windows. The classes hide the details that you don't need to worry about for many applications, providing a simple API for rapid prototyping. For example:
TcpSocketClient client("localhost", 5000);
client.openConnection();
char message[100] = "Hello from client!";
client.sendData(message, strlen(message));
client.receiveData(message, 100);
The class header code is in the sockets folder, which you can copy/paste into your own project.
% git clone -b test_windows https://github.com/simondlevy/CppSockets
% cd CppSockets
% git clone https://github.com/simondlevy/CppSockets sockets
Then open the UdpClient and UdpServer projects, and run them in Release mode.
% git clone -b test_linux https://github.com/simondlevy/CppSockets
% cd CppSockets
% git clone https://github.com/simondlevy/CppSockets sockets
% make
Then you can run one of the two pairs of resulting test programs (udpsever/udpclient, tcpsever/tcpclient).