I see that the poll() system call returns the POLLIN event even after the socket has been closed by the peer. I see both POLLIN and POLLERR set. And this continues to happen even after the read() call has returned -1.
My logic handles POLLERR only if there is no POLLIN to make sure I read any packets that are already arrived before the socket got disconnected. As a result I never end up handling POLLERR since POLLIN is always set.
Why is poll() returning POLLIN along with POLLERR after a socket error? And how should I handle this scenario.
Thanks!