Simple socket programming library in C++, that facilitates using sockets in c++ as it provides an easy interface for socket programming functions.
socket.cpp library tends to provide an interface of sockets functions similar to JavaScript's socket.io
framework.
Here is a few example of library usage:
TCP Server
// create simple tcp server
int port = 4000;
tcp::server server(port);
server.OnMessage(PrintMessage);
server.Listen();
TCP Client
// create simple tcp client and connect to server
int port = 4000;
string address = "127.0.0.1";
tcp::client client( address, port);
client.Connect();
client.Send("Hi");
If you want to modify how library is implemented, click the Fork
button in the top-right corner of this page, and then clone your fork from the command line by replacing [username] with your GitHub user name:
git clone https://github.com/[username]/socket.cpp.git
Building process has been tested using GNU Make 3.81
and g++ 4.9.2
And library can be build easily as follows:
git clone https://github.com/samehkamaleldin/socket.cpp.git
cd ./socket.cpp/build
make
And the target library socket-cpp.so
and binaries for examples can be found in dist
directory under repositories home directory.
The development of this library has been inspired by a set of code documentation pages, C++ examples and tutorials about C/C++ socket programming such as:-