0
votes

I use epoll linux server for multiplexing. I noticed that the request to close the connection occurs in two ways:

  1. the EPOLLHUP event fires
  2. recv returns 0

It’s not entirely clear to me what the client should do so that we get EPOLLHUP on the server, and it’s also not clear what the client should do so that we get 0 on the server with recv.

I just need to close the connection in the right way, but I don't know how.

close()? Maybe. - Jesper Juhl
I think we can get 0 from recv and EPOLLHUP in different situations. This is right? - Joseph Conrad
stackoverflow.com/questions/52976152/… says this is generated only if the socket has been shut down in both directions. My suggestion: just treat EPOLLHUP the same as EPOLLIN - when you call recv you'll get 0 - user253751