Fix detection of TCP connection failure.