MCPcopy Create free account
hub / github.com/amule-project/amule / OnConnect

Method OnConnect

src/ServerSocket.cpp:84–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84void 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
128void CServerSocket::OnReceive(int nErrorCode)
129{

Callers 1

LibSocketConnectFunction · 0.45

Calls 5

HasDynIPMethod · 0.80
SetIDMethod · 0.80
GetServerByAddressMethod · 0.45
GetPortMethod · 0.45
DestroySocketMethod · 0.45

Tested by

no test coverage detected