void connection::connect(resolver::iterator iterator) { socket_.async_connect(*iterator, boost::bind( &connection::handle_connect, this, _1, iterator) ); LOG_NW << "Connecting to " << iterator->endpoint().address() << '\n'; }
// main thread void wesnothd_connection::handle_connect(const boost::system::error_code& ec, resolver::iterator iterator) { MPTEST_LOG; if(ec) { WRN_NW << "Failed to connect to " << iterator->endpoint().address() << ": " << ec.message() << '\n'; socket_.close(); if(++iterator == resolver::iterator()) { ERR_NW << "Tried all IPs. Giving up" << std::endl; throw system_error(ec); } else { connect(iterator); } } else { LOG_NW << "Connected to " << iterator->endpoint().address() << '\n'; handshake(); } }
// main thread void wesnothd_connection::connect(resolver::iterator iterator) { MPTEST_LOG; socket_.async_connect(*iterator, std::bind(&wesnothd_connection::handle_connect, this, _1, iterator)); LOG_NW << "Connecting to " << iterator->endpoint().address() << '\n'; }