With the polymorphic and inheritance features of C++, use Epoll to implement TCP server/client, and UDP.
Epoll
is the core of system. All fd(s) Epoll.Join
to poll read/write events. The system started working with Epoll.Wait
.
Listener
is used to implement TCP server. Listener.OnAccept
will establish incomming connection by Connection
. Connector
is used to implement TCP client.
Connector
and Connection
are a pair of TCP stream, implement OnRecv
, OnClose
by yourself. Enqueue
is used to enqueue output data.
Peer
is used to implement UDP application. Implement OnRecv
by yourself.
Refer examples
-
TCP server and client:
-
UDP pairs:
UDP Server and UDP Client
-
Chat server: