Assuming a TCP socket, the client (or server) won't know the other side closed down until a recv(2) on the socket returns 0.