Check that the socket is still valid before reading or writing to it. There seems to be a window where the client can prematurely close the connection before we've finished reading or writing. This is harmless, but it causes potentially confusing errors in the logs.