recv() returns 0 when the connection of a connection-oriented socket has
been closed. It also returns 0 when a zero-length datagram is received,
for connectionless sockets.
The usual case is the first scenario and is normal. When you receive 0
bytes, your connection is closed and you should close the socket and
discard it.
Note that select() will indicate the socket is readable, since it is. The
return value of 0 isn't a failure; it's a normal, successful read that
tells you something specific about the state of the socket.
Pete