Linux-Network-Programming icon indicating copy to clipboard operation
Linux-Network-Programming copied to clipboard

Sample codes for Linux network programming based on socket and I/O multiplexing in C++11, revealing the essence of computer network communication through packet capture.

trafficstars

Supported Platforms Build Status GitHub license

Documentation

  • 通过抓包理解 TCP 与 UDP
  • 基本 TCP 套接字 API
  • 网络编程 I/O 模型
  • Linux I/O 多路复用 API:select、poll、epoll

Build and Run

  • build
git clone [email protected]:downdemo/Linux-Network-Programming.git
cd Linux-Network-Programming
make
  • Service would be generated in build directory
cd build
  • Run server before client
  • One running server at most because samples use the same port 12345
  • Ctrl + c to interrupt blocking server and client process

Run UDP sample

  • Run server
./udp_server
  • Run client in another shell
./udp_client

Run socket sample

  • Run server
./socket_server
  • Run client
./socket_client

Run fork sample

  • Run server
./fork_server
  • Run client multiple times
./fork_client
./fork_client
./fork_client
./fork_client
./fork_client

Run select samplepoll sampleepoll sample

  • Run any I/O multiplexing server, such as epoll_server
./epoll_server
  • Run multiple I/O multiplexing clients
./select_client
./select_client
./poll_client
./poll_client
./epoll_client
./epoll_client

RFC