| 577 | } |
| 578 | |
| 579 | void CServerSocket::ConnectToServer(CServer* server, bool bNoCrypt) |
| 580 | { |
| 581 | AddDebugLogLineN(logServer, "Trying to connect"); |
| 582 | |
| 583 | if (cur_server){ |
| 584 | wxFAIL; |
| 585 | delete cur_server; |
| 586 | cur_server = NULL; |
| 587 | } |
| 588 | |
| 589 | cur_server = new CServer(server); |
| 590 | |
| 591 | m_bNoCrypt = bNoCrypt; |
| 592 | |
| 593 | SetConnectionState(CS_CONNECTING); |
| 594 | |
| 595 | info = cur_server->GetListName(); |
| 596 | |
| 597 | // This must be used if we want to reverse-check the addr of the server |
| 598 | if (cur_server->HasDynIP() || !cur_server->GetIP()) { |
| 599 | m_IsSolving = true; |
| 600 | // Send it to solving thread. |
| 601 | CAsyncDNS* dns = new CAsyncDNS(server->GetAddress(), DNS_SERVER_CONNECT, theApp, this); |
| 602 | |
| 603 | if ( dns->Create() == wxTHREAD_NO_ERROR ) { |
| 604 | if ( dns->Run() != wxTHREAD_NO_ERROR ) { |
| 605 | dns->Delete(); |
| 606 | AddLogLineN(CFormat( _("Cannot create DNS solving thread for connecting to %s") ) % cur_server->GetAddress()); |
| 607 | } |
| 608 | } else { |
| 609 | dns->Delete(); |
| 610 | AddLogLineN(CFormat( _("Cannot create DNS solving thread for connecting to %s") ) % cur_server->GetAddress()); |
| 611 | } |
| 612 | } else { |
| 613 | // Nothing to solve, we already have the IP |
| 614 | OnHostnameResolved(cur_server->GetIP()); |
| 615 | } |
| 616 | |
| 617 | } |
| 618 | |
| 619 | void CServerSocket::OnError(int DEBUG_ONLY(nErrorCode)) |
| 620 | { |