Correctly handle disconnecting clients

Receiving 0 bytes from a socket means that the client has closed the
connection. Handle this correctly by accepting a new client instead of
continuing to read 0 bytes.