Tiny object-oriented header-only sockets library It supports both UDP and TCP
There are Socket and Connection classes. You can inherit from Connection class and override << and >> operators for every class you want to transfer. Socket classes are not for direct use.
There are TCP and UDP client and server template classes.
You can use them with your Connection class.
There are SocketException class
Tests for Communicators Now there are only Send/Recv tests
Just inherit from Connection class and implement methods '>>' '<<' for your struct or class
Then use this class as a type in TCP/UDP/Client/Server templates.
Server and client returns Connection object, when the connection is established
(methods AcceptConnection()
for Server classes and Connect()
for Client classes)
Every Client has
TemplateConnection Connect(const std::string ip, const int port)
Every Server class has
TemplateConnection AcceptConnection()
It binds one socket and listens to incoming connections.
When a new connection request comes,
it opens a new socket via accept()
and creates a new connection with a client.
It does not need to bind its address to the socket.
It just calls connect()
method with server address.
It binds its port and awaits requests via recvfrom()
.
In recvfrom()
it explicitly binds to the incoming connection.
It calls sendto()
with the address of a server.