If recv returns 0 this means that the peer has closed the socket.
recv won't throw because its a C function.
If there's an error recv will return -1. In which case your application has to check the type of error. Note that a return of -1 does not imply that the peer has closed its socket.