Async connect and disconnect with epoll (Linux)

前端 未结 4 2041
无人共我
无人共我 2020-12-07 23:45

I need async connect and disconnect for tcp client using epoll for Linux. There are ext. functions in Windows, such as ConnectEx, DisconnectEx, AcceptEx, etc... In tcp serv

4条回答
  •  遥遥无期
    2020-12-08 00:16

    From experience, when detect non-blocking connection , epoll is a little different from select and poll.

    with epoll:

    After connect() call is made, check return code.

    If the connection can not be completed immediately, then register EPOLLOUT event with epoll.

    Call epoll_wait().

    if the connection failed, your events will be fill with EPOLLERR or EPOLLHUP, otherwise EPOLLOUT will be triggered.

提交回复
热议问题