Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
When reading from a channel such as a pipe or a stream socket,
this event merely indicates that the peer closed its end of the channel.
EPOLLRDHUP
Stream socket peer closed connection, or shut down writing half of connection.
I can hardly tell any difference between
EPOLLHUP
and
EPOLLRDHUP
.
To me, whenever
EPOLLRDHUP
is used
EPOLLHUP
can be used instead with the same semantics.
Am I right? If not, any explanations?
–
–
–
EPOLLHUP
means that the peer closed their end of the connection.
Writing to the connection is closed
, and after any (possible) readable data is consumed, reading from the connection is closed, too.
EDPOLLRDHUP
only means that the peer closed their connection, or only half of their connection. If it's only halfway closed, the stream socket turns into a one-way, write-only connection.
Writing to the connection may still be open
, but after any (possible) readable data is consumed, reading from the connection is closed.
This may be done if the peer calls
shutdown()
on their socket descriptor, disallowing itself from writing data:
#include <sys/socket.h>
int sockfd = /* ... */;
shutdown(sockfd, SHUT_WR);
–
–