From c030e602e52034a4dc9f26b76e55ecd272f4cf6f Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 8 Dec 2016 19:59:16 +0100 Subject: [PATCH] Properly handle tcp connection failure (cherry picked from commit 4f07b595a17a633c65c5df43ecdaa37667a475e9) --- drivers/unix/stream_peer_tcp_posix.cpp | 7 ++++++- platform/windows/stream_peer_winsock.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index b1636abd692..19f1ed4b347 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -107,7 +107,12 @@ Error StreamPeerTCPPosix::_poll_connection(bool p_block) const { return OK; }; - return OK; + if (errno == EINPROGRESS || errno == EALREADY) { + return OK; + } + + status = STATUS_ERROR; + return ERR_CONNECTION_ERROR; } else { status = STATUS_CONNECTED; diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp index 44c17c73e5e..48dd37e9c44 100644 --- a/platform/windows/stream_peer_winsock.cpp +++ b/platform/windows/stream_peer_winsock.cpp @@ -98,7 +98,12 @@ Error StreamPeerWinsock::_poll_connection(bool p_block) const { return OK; }; - return OK; + if (errno == WSAEINPROGRESS || errno == WSAEALREADY) { + return OK; + } + + status = STATUS_ERROR; + return ERR_CONNECTION_ERROR; } else { status = STATUS_CONNECTED;