本文整理汇总了C++中boost::asio::ip::tcp::socket::async_connect方法的典型用法代码示例。如果您正苦于以下问题:C++ socket::async_connect方法的具体用法?C++ socket::async_connect怎么用?C++ socket::async_connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::ip::tcp::socket
的用法示例。
在下文中一共展示了socket::async_connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoConnect
//===========================================================================
void CHttpClient::DoConnect (
const boost::system::error_code & err,
boost::asio::ip::tcp::resolver::iterator iter
) {
if (err) {
if (iter != boost::asio::ip::tcp::resolver::iterator()) {
m_socket.close();
boost::asio::ip::tcp::endpoint endPoint = *iter;
auto handler = boost::bind(
&CHttpClient::DoConnect,
this,
boost::asio::placeholders::error,
++iter
);
m_socket.async_connect(endPoint, handler);
} else {
printf("%s\n", __FUNCTION__);
cout<<"Error: "<<err.message()<<endl;
}
return;
}
auto handler = boost::bind(
&CHttpClient::DoWriteRequest,
this,
boost::asio::placeholders::error
);
boost::asio::async_write(m_socket, m_request, handler);
}
示例2: DoResolve
//===========================================================================
void CHttpClient::DoResolve (
const boost::system::error_code & err,
boost::asio::ip::tcp::resolver::iterator iter
) {
if (err) {
printf("%s\n", __FUNCTION__);
cout<<"Error: "<<err.message()<<endl;
return;
}
boost::asio::ip::tcp::endpoint endPoint = *iter;
auto handler = boost::bind(
&CHttpClient::DoConnect,
this,
boost::asio::placeholders::error,
++iter
);
m_socket.async_connect(endPoint, handler);
}
示例3: connect
void connect(Func handler, boost::asio::ip::tcp::endpoint ep)
{
s_opt.async_connect(ep, handler);
}