void SctpSocket::OnException() { if (Connecting()) { #ifdef ENABLE_SOCKS4 if (Socks4()) OnSocks4ConnectFailed(); else #endif if (GetConnectionRetry() == -1 || (GetConnectionRetry() && GetConnectionRetries() < GetConnectionRetry() )) { // even though the connection failed at once, only retry after // the connection timeout // should we even try to connect again, when CheckConnect returns // false it's because of a connection error - not a timeout... } else { SetConnecting(false); // tnx snibbe SetCloseAndDelete(); OnConnectFailed(); } return; } // %! exception doesn't always mean something bad happened, this code should be reworked // errno valid here? int err = SoError(); Handler().LogError(this, "exception on select", err, StrError(err), LOG_LEVEL_FATAL); SetCloseAndDelete(); }
void CPeerLink::HandleClose() { if (m_nPeerState == PS_CONNECTING) { m_nPeerState = PS_CONNECTFAILED; OnConnectFailed(); } if (m_nPeerState == PS_ESTABLISHED) { m_nPeerState = PS_CLOSED; OnConnectClosed(); } if (m_nConnTimeoutID != 0) { GetReactor()->RemoveTimer(m_nConnTimeoutID); m_nConnTimeoutID = 0; } m_bCanRead = false; m_bCanWrite = false; SetReactor(NULL); CWinSocket::Close(); }
//-------------------------------------------------------------------------- void Connection::ConnectFailed(ConnectFail eFail) { if(m_pkServer && m_pkServer->IsServerConnected()) { m_pkServer->OnDisconnect(); m_pkServer->SetServerID(UNASSIGNED_SYSTEM_ADDRESS); } OnConnectFailed(eFail); Disconnect(); }
void SctpSocket::OnConnectTimeout() { Handler().LogError(this, "connect", -1, "connect timeout", LOG_LEVEL_FATAL); #ifdef ENABLE_SOCKS4 if (Socks4()) { OnSocks4ConnectFailed(); // retry direct connection } else #endif if (GetConnectionRetry() == -1 || (GetConnectionRetry() && GetConnectionRetries() < GetConnectionRetry()) ) { IncreaseConnectionRetries(); // ask socket via OnConnectRetry callback if we should continue trying if (OnConnectRetry()) { SetRetryClientConnect(); } else { SetCloseAndDelete( true ); /// \todo state reason why connect failed OnConnectFailed(); } } else { SetCloseAndDelete(true); /// \todo state reason why connect failed OnConnectFailed(); } // SetConnecting(false); }
void SctpSocket::OnWrite() { if (Connecting()) { int err = SoError(); // don't reset connecting flag on error here, we want the OnConnectFailed timeout later on /// \todo add to read fd_set here if (!err) // ok { Set(!IsDisableRead(), false); SetConnecting(false); SetCallOnConnect(); return; } Handler().LogError(this, "sctp: connect failed", err, StrError(err), LOG_LEVEL_FATAL); Set(false, false); // no more monitoring because connection failed // failed #ifdef ENABLE_SOCKS4 if (Socks4()) { OnSocks4ConnectFailed(); return; } #endif if (GetConnectionRetry() == -1 || (GetConnectionRetry() && GetConnectionRetries() < GetConnectionRetry()) ) { // even though the connection failed at once, only retry after // the connection timeout. // should we even try to connect again, when CheckConnect returns // false it's because of a connection error - not a timeout... return; } SetConnecting(false); SetCloseAndDelete( true ); /// \todo state reason why connect failed OnConnectFailed(); return; } }