【发布时间】:2020-10-20 12:46:44
【问题描述】:
我使用函数async_resolve()
using tcp = boost::asio::ip::tcp;
namespace asio = boost::asio;
template <class Request, class Response>
class HttpsClient : public std::enable_shared_from_this<HttpsClient<Request, Response>>
{
mutable asio::io_context::strand m_strand;
tcp::resolver m_resolver;
const std::string m_host;
const std::string m_service;
void doSend(Request request, Handler handler)
{
...
m_resolver.async_resolve(
m_host, m_service,
asio::bind_executor(
m_strand, std::bind(&HttpsClient::onResolve, this->shared_from_this(), _1, _2)
)
);
...
}
void onResolve(const boost::system::error_code& ec, tcp::resolver::results_type results);
我是否应该取消async_resolve(),例如在超时后?
我的问题是 - async_resolve() 是否提供任何保证以在智能时间限制内返回。
【问题讨论】:
标签: c++ c++11 network-programming boost-asio