I wrote a socket server, running on linux, but this is probably not linux specifix.
I use poll()
to check the state of the clients. My clients do an active (half-)close after sending the request. The server constantly getting POLLHUP
and POLLERR
, because of the client's half-close. I also see POLLRDHUP
, so I know that's actually half-close and not a connection close/reset. My problem is that I always get these events even though I already know from previous poll that there was a half-close.
How can I disable this so I do not receive theis event anymore? I tried to do additional read()
and do a shutdown(fd, SHUT_RD)
, but it doesn't seem to help. I don't want poll
to wake up for an event I already handled.
Stop including the fd in the readfds set once you get the half close. There's nothing left to read except half-closes. From this point the only thing you can be interested in is 'writable' events.