From 9f387f5cf3a9a29e3aca97bdf316076535f50c45 Mon Sep 17 00:00:00 2001 From: death2droid Date: Tue, 29 Dec 2009 22:41:49 +0000 Subject: [PATCH] Add a fix to our SFML from the current svn version of SFML. Its meant to fix a problem when the connection timed out it used to return that it had connected. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4751 8ced0084-cf51-0410-be5f-012b33b47a6e --- Externals/SFML/src/SFML/Network/SocketTCP.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Externals/SFML/src/SFML/Network/SocketTCP.cpp b/Externals/SFML/src/SFML/Network/SocketTCP.cpp index eb32179b30..e4a4aa7f20 100644 --- a/Externals/SFML/src/SFML/Network/SocketTCP.cpp +++ b/Externals/SFML/src/SFML/Network/SocketTCP.cpp @@ -131,11 +131,22 @@ Socket::Status SocketTCP::Connect(unsigned short Port, const IPAddress& HostAddr Time.tv_sec = static_cast(Timeout); Time.tv_usec = (static_cast(Timeout * 1000) % 1000) * 1000; - // Wait for something to write on our socket (would mean the connection has been accepted) + // Wait for something to write on our socket (which means that the connection request has returned) if (select(static_cast(mySocket + 1), NULL, &Selector, NULL, &Time) > 0) { - // Connection succeeded - Status = Socket::Done; + // At this point the connection may have been either accepted or refused. + // To know whether it's a success or a failure, we try to retrieve the name of the connected peer + SocketHelper::LengthType Size = sizeof(SockAddr); + if (getpeername(mySocket, reinterpret_cast(&SockAddr), &Size) != -1) + { + // Connection accepted + Status = Socket::Done; + } + else + { + // Connection failed + Status = SocketHelper::GetErrorStatus(); + } } else {