Browse Source

Properly handle tcp connection failure

(cherry picked from commit 4f07b595a17a633c65c5df43ecdaa37667a475e9)
Fabio Alessandrelli 8 years ago
parent
commit
c030e602e5
2 changed files with 12 additions and 2 deletions
  1. 6 1
      drivers/unix/stream_peer_tcp_posix.cpp
  2. 6 1
      platform/windows/stream_peer_winsock.cpp

+ 6 - 1
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;

+ 6 - 1
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;