It's my personal exercise.
The core implementation is in TcpServer & TcpClient classes. recv/send functions are independent from them.
Most of I/O operations are in nonblock mode. (But it's so hard to write! I dont think it's a good idea to write all I/O operations in nonblock mode. It depends on the actual situation.)
Any application can inherit from TcpServer and rewrite certain methods to implement its own protocol.
HttpServer inherits from TcpServer for example. It reads files from html/ and deliver them to client with sendfile().
TcpServer default Message format:
msg_len(2 bytes, max num 65535, network sequence, including msg_len itself) | msg_body
GOAL:
- basic tcp_server.c with recv & print capability OK
- basic tcp_client.c with send capability OK
- rewrite tcp_server.c using epoll OK
- rewrite tcp_server.c to cpp in class & exception style OK
- rewrite tcp_client.c to cpp, extracting common part to tcp_public OK
- adding client recv & server send capability OK
- decopling message parse & deal part OK