mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 05:53:26 +02:00
connection is now working properly
This commit is contained in:
@@ -57,16 +57,18 @@ void Connection::connect(const std::string& ip, uint16 port)
|
||||
logDebug("connecting...");
|
||||
|
||||
//first resolve dns
|
||||
boost::asio::ip::tcp::resolver::query query(ip, "80");
|
||||
boost::asio::ip::tcp::resolver::query query(ip, convertType<std::string, uint16>(port));
|
||||
m_resolver.async_resolve(query, boost::bind(&Connection::onResolveDns, this, boost::asio::placeholders::error, boost::asio::placeholders::iterator));
|
||||
}
|
||||
|
||||
void Connection::onResolveDns(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
|
||||
{
|
||||
logDebug("resolving dns..");
|
||||
|
||||
m_lastError = error;
|
||||
|
||||
if(error){
|
||||
m_connecting = false;
|
||||
m_lastError = error;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,9 +78,10 @@ void Connection::onResolveDns(const boost::system::error_code& error, boost::asi
|
||||
|
||||
void Connection::onConnect(const boost::system::error_code& error)
|
||||
{
|
||||
m_lastError = error;
|
||||
|
||||
if(error){
|
||||
m_connecting = false;
|
||||
m_lastError = error;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,8 @@ public:
|
||||
bool isConnected() const { return m_connected; }
|
||||
|
||||
const boost::system::error_code& getLastError() const { return m_lastError; }
|
||||
|
||||
void resetLastError() { m_lastError = boost::system::error_code(); }
|
||||
|
||||
private:
|
||||
void onResolveDns(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
|
||||
|
Reference in New Issue
Block a user