Socket 编程

Basic

img

Code

epoll

methods

1
2
3
epoll_create(...)  // 创建 epoll
epoll_ctl(...) // 向 epoll 注册 socketfd
epoll_wait(...) // 从 epoll 获取事件

steps

  • socket()
  • bind()
  • listen()
  • epoll
    • epoll_create()
    • epoll_ctl() : Add server socket to epoll instance
    • epoll_wait()
  • accept()
  • epoll_ctl() : Add client socket to epoll instance
  • read()
  • write()

Reference