Save the last error from receive()
Close the socket on error.