A simple c++ socket library that makes it easier to use sockets on different platforms (Linux and Windows). To separate the work with sockets, two socket interfaces are made - the client and the server. This project was made to adapt the work with sockets on different platforms.
int Configuration(int protocol)- this method is needed to configure the socket and prepare it for operationint Connect(const int port, const char* address)- this method is needed to connect to another user's socketint Send(const void* data, const int size)- This method is needed to send data over the selected protocol in the configurationint Receive(const void* data, const int size)- this method is needed to receive data sent by another user or server
int Configuration(int protocol)- this method is needed to configure the socket and prepare it for operationint Bind(const int port, const char* address)- this method is needed to bind socket to port, and get data from all or from single addressint Listen(int backlog)- This method is needed to allow socket to listen for connectionsIClientSocket* Accept()- this method is needed to connect permits an incoming connection request to the socket
Building process has been tested using CMake 3.27 and g++ 4.9.2 And library can be build easily as follows:
git clone https://github.com/Claucdan/CSocket.git
cd ./CSocket/
cmake -S . ./cmake-build
cmake --build .You can use that library like fetch content in CMake.
include(FetchContent)
FetchContent_Declare(
CSocket
GIT_REPOSITORY https://github.com/Claucdan/CSocket.git
GIT_TAG v1.1.27
)
FetchContent_MakeAvailable(CSocket)