Пример #1
0
//===========================================================================
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
0
//===========================================================================
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
0
	void connect(Func handler, boost::asio::ip::tcp::endpoint ep)
	{
		s_opt.async_connect(ep, handler);
	}