# HG changeset patch # User David Demelier # Date 1414947475 -3600 # Node ID d2d5a14bae101f2c409a6aeb9131e31549544aaa # Parent ea55a3886da0935db8917f44364077b923177fbc Socket: check for POLLHUP if the socket has disconnect. Some implementations mark the socket POLLIN whilst some other mark it POLLHUP. diff -r ea55a3886da0 -r d2d5a14bae10 C++/SocketListener.cpp --- a/C++/SocketListener.cpp Mon Oct 27 11:20:49 2014 +0100 +++ b/C++/SocketListener.cpp Sun Nov 02 17:57:55 2014 +0100 @@ -174,7 +174,14 @@ { int direction{}; - if (event & POLLIN) + /* + * Poll implementations mark the socket differently regarding + * the disconnection of a socket. + * + * At least, even if POLLHUP or POLLIN is set, recv() always + * return 0 so we mark the socket as readable. + */ + if ((event & POLLIN) || (event & POLLHUP)) direction |= Read; if (event & POLLOUT) direction |= Write;