From bdedf6a87f0046b0f045147d4559776af5de4d5b Mon Sep 17 00:00:00 2001 From: Fletcher Dunn Date: Mon, 2 Sep 2019 12:53:57 -0700 Subject: [PATCH] Added spew if AcceptConnection fails --- .../clientlib/csteamnetworkingsockets.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp b/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp index f88c6b2..0d5fd05 100644 --- a/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp +++ b/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp @@ -580,16 +580,32 @@ EResult CSteamNetworkingSockets::AcceptConnection( HSteamNetConnection hConn ) SteamDatagramTransportLock scopeLock; CSteamNetworkConnectionBase *pConn = GetConnectionByHandle( hConn ); if ( !pConn ) + { + SpewError( "Cannot accept connection #%u; invalid connection handle", hConn ); return k_EResultInvalidParam; + } // Should only be called for connections accepted on listen socket. // (E.g., not connections initiated locally.) if ( pConn->m_pParentListenSocket == nullptr ) + { + SpewError( "[%s] Should not be trying to acccept this connection, it was not received on a listen socket.", pConn->GetDescription() ); return k_EResultInvalidParam; + } // Must be in in state ready to be accepted if ( pConn->GetState() != k_ESteamNetworkingConnectionState_Connecting ) + { + if ( pConn->GetState() == k_ESteamNetworkingConnectionState_ClosedByPeer ) + { + SpewWarning( "[%s] Cannot accept connection; already closed by remote host.", pConn->GetDescription() ); + } + else + { + SpewError( "[%s] Cannot accept connection, current state is %d.", pConn->GetDescription(), pConn->GetState() ); + } return k_EResultInvalidState; + } // Protocol-specific handling return pConn->APIAcceptConnection();