Async connect and disconnect with epoll (Linux)

前端 未结 4 2048
无人共我
无人共我 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:34

    I have tried the Sonny's solution and the epoll_ctl will return invalid argument. So i think maybe the right way to do this is as follow:

    1.create socketfd and epollfd

    2.use epoll_ctl to associate the socketfd and epollfd with epoll event.

    3.do connect(socketfd,...)

    4.check the return value or errno

    5.if errno == EINPROGRESS, do epoll_wait

提交回复
热议问题