Skip to content

Commit

Permalink
Another attempt to use more advanced boost in the examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Jan 8, 2025
1 parent 56dc7a8 commit 8593089
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ bool Client::start()
{
boost::asio::ip::tcp::resolver resolver(m_io);
boost::system::error_code ec;
auto iter = resolver.resolve(m_server, std::to_string(m_port), ec);
auto resolveResult = resolver.resolve(m_server, std::to_string(m_port), ec);
if (ec) {
std::cerr << "ERROR: Failed to resolve \"" << m_server << ':' << m_port << "\" " <<
"with error: " << ec.message() << std::endl;
return false;
}

auto endpoint = iter->endpoint();
if (resolveResult.empty()) {
std::cerr << "ERROR: No resolution result" << std::endl;
return false;
}

auto endpoint = resolveResult.begin()->endpoint();
m_socket.connect(endpoint, ec);
if (ec) {
std::cerr << "ERROR: Failed to connect to \"" << endpoint << "\" " <<
Expand Down

0 comments on commit 8593089

Please sign in to comment.