I'm currently trying to build a project without any deprecated methods and hit a problem with the resolver. My old code used to look like this:
const asio::ip::tcp::resolver::query query(params.host, std::to_string(params.port));
m_resolver.async_resolve(query, [&](const std::error_code &ec_, asio::ip::tcp::resolver::iterator iter) {
if (ec_) {
ec = ec_;
return;
}
while (iter != asio::ip::tcp::resolver::iterator()) {
m_socket.reset(new asio::generic::stream_protocol::socket(m_service));
m_socket->async_connect((*iter++).endpoint(), [&](const std::error_code &err_code) {
if (err_code) {
ec = err_code;
return;
}
connected = true;
});
};
});
But now Asio says asio::tcp::resolver::query is deprecated. How is hostname resolution done now?
Aucun commentaire:
Enregistrer un commentaire