Workaround broken connect implementation.

This commit is contained in:
Bartosz Taudul 2020-06-20 18:35:21 +02:00
parent 5ccd62ced8
commit f7727f3aa4

View File

@ -113,7 +113,8 @@ bool Socket::Connect( const char* addr, int port )
if( m_ptr )
{
const auto c = connect( m_connSock, m_ptr->ai_addr, m_ptr->ai_addrlen );
assert( c == -1 );
if( c == -1 )
{
#if defined _WIN32 || defined __CYGWIN__
const auto err = WSAGetLastError();
if( err == WSAEALREADY || err == WSAEINPROGRESS ) return false;
@ -125,14 +126,16 @@ bool Socket::Connect( const char* addr, int port )
return false;
}
#else
if( errno == EALREADY || errno == EINPROGRESS ) return false;
if( errno != EISCONN )
const auto err = errno;
if( err == EALREADY || err == EINPROGRESS ) return false;
if( err != EISCONN )
{
freeaddrinfo( m_res );
close( m_connSock );
m_ptr = nullptr;
return false;
}
}
#endif
#if defined _WIN32 || defined __CYGWIN__