Handle tcp failures while reading from the socket (more) correctly.