| 82 | |
| 83 | |
| 84 | void CServerSocket::OnConnect(int nErrorCode) |
| 85 | { |
| 86 | switch (nErrorCode) { |
| 87 | case boost::system::errc::success: |
| 88 | if (cur_server->HasDynIP()) { |
| 89 | uint32 server_ip = GetPeerInt(); |
| 90 | cur_server->SetID(server_ip); |
| 91 | // GetServerByAddress may return NULL, so we must test! |
| 92 | // This was the reason why amule would crash when trying to |
| 93 | // connect in wxWidgets 2.5.2 |
| 94 | CServer *pServer = theApp->serverlist->GetServerByAddress( |
| 95 | cur_server->GetAddress(), cur_server->GetPort()); |
| 96 | if (pServer) { |
| 97 | pServer->SetID(server_ip); |
| 98 | } else { |
| 99 | AddDebugLogLineN(logServer, "theApp->serverlist->GetServerByAddress() returned NULL"); |
| 100 | return; |
| 101 | } |
| 102 | } |
| 103 | SetConnectionState(CS_WAITFORLOGIN); |
| 104 | break; |
| 105 | |
| 106 | case boost::system::errc::address_in_use: |
| 107 | case boost::system::errc::address_not_available: |
| 108 | case boost::system::errc::bad_address: |
| 109 | case boost::system::errc::connection_refused: |
| 110 | case boost::system::errc::host_unreachable: |
| 111 | case boost::system::errc::invalid_argument: |
| 112 | case boost::system::errc::timed_out: |
| 113 | m_bIsDeleting = true; |
| 114 | SetConnectionState(CS_SERVERDEAD); |
| 115 | serverconnect->DestroySocket(this); |
| 116 | return; |
| 117 | |
| 118 | default: |
| 119 | m_bIsDeleting = true; |
| 120 | SetConnectionState(CS_FATALERROR); |
| 121 | serverconnect->DestroySocket(this); |
| 122 | return; |
| 123 | |
| 124 | } |
| 125 | |
| 126 | } |
| 127 | |
| 128 | void CServerSocket::OnReceive(int nErrorCode) |
| 129 | { |
no test coverage detected