From db3ffab8325b83c1b183fa4f9b31029c3fa2cfaa Mon Sep 17 00:00:00 2001 From: Chris Millsap Date: Tue, 11 Apr 2017 14:51:29 -0400 Subject: [PATCH 1/2] Possible fix to issue #1951 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Code formated to be submitted for pull request) -- Indentation was off. SAME FIX AS BEFORE When two instances of Torque3D are running on the same network, one as a hosted server and the other as a client, the client is unable to connect to the server. The program now can open a socket. This was obviously a typo. To find the error I just searched for keywords containing socket, open, open socket, and opensocket till I found the correct file. The other error was in how the program processed “non fatal” errors. I just outputed the error to the main console and devised that the socket should not be closed for a WSAEWOULDBLOCK error 10035 "It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established." Read about the WouldBlock error: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx Use of dbgSetParameters ( port , password ): http://docs.garagegames.com/tge/official/content/documentation/Reference/Console%20Functions/TorqueScript_Console_Functions_2.html#dbgSetParameters_.28_port_.2C_password_.29 --- Engine/source/platform/platformNet.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Engine/source/platform/platformNet.cpp b/Engine/source/platform/platformNet.cpp index f2464b9bc..3ab659d50 100644 --- a/Engine/source/platform/platformNet.cpp +++ b/Engine/source/platform/platformNet.cpp @@ -809,7 +809,7 @@ NetSocket Net::openConnectTo(const char *addressString) error = Net::WrongProtocolType; } - if (error != NoError || error == NeedHostLookup) + if (error == NoError || error == NeedHostLookup) // Open socket { handleFd = openSocket(); } @@ -826,10 +826,15 @@ NetSocket Net::openConnectTo(const char *addressString) if (::connect(socketFd, (struct sockaddr *)&ipAddr, sizeof(ipAddr)) == -1 && errno != EINPROGRESS) { - Con::errorf("Error connecting %s: %s", - addressString, strerror(errno)); - closeSocket(handleFd); - handleFd = NetSocket::INVALID; + error = PlatformNetState::getLastError(); // Output this error if not 10035 then close + + if (error != Net::WouldBlock) // Resource temporarily unavailable. + { + Con::errorf("Error connecting %s: %s", + addressString, strerror(errno)); + closeSocket(handleFd); + handleFd = NetSocket::INVALID; + } } } else From 55f34305718a49e68d5d71261003a9e0e2c1a754 Mon Sep 17 00:00:00 2001 From: Chris Millsap Date: Wed, 12 Apr 2017 18:54:59 -0400 Subject: [PATCH 2/2] Comment formatting Removed incorrect comments to be more inline with windows and linux. Put comment on line 812 on top of code. --- Engine/source/platform/platformNet.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Engine/source/platform/platformNet.cpp b/Engine/source/platform/platformNet.cpp index 3ab659d50..2114633ca 100644 --- a/Engine/source/platform/platformNet.cpp +++ b/Engine/source/platform/platformNet.cpp @@ -809,7 +809,8 @@ NetSocket Net::openConnectTo(const char *addressString) error = Net::WrongProtocolType; } - if (error == NoError || error == NeedHostLookup) // Open socket + // Open socket + if (error == NoError || error == NeedHostLookup) { handleFd = openSocket(); } @@ -826,9 +827,9 @@ NetSocket Net::openConnectTo(const char *addressString) if (::connect(socketFd, (struct sockaddr *)&ipAddr, sizeof(ipAddr)) == -1 && errno != EINPROGRESS) { - error = PlatformNetState::getLastError(); // Output this error if not 10035 then close + error = PlatformNetState::getLastError(); - if (error != Net::WouldBlock) // Resource temporarily unavailable. + if (error != Net::WouldBlock) { Con::errorf("Error connecting %s: %s", addressString, strerror(errno));