Boost logo

Boost Users :

Subject: [Boost-users] Passing * to member function as parameter
From: Etienne Philip Pretorius (icewolfhunter_at_[hidden])
Date: 2010-04-20 07:13:18


Hello List,

I am using boost::asio. My client performs a lot of async read requests
and then only responds to those with a write operation. How would I pass
a pointer to a member function from the read request to the write
handler to call when it performs the write.

void handle_read_banner(
    const boost::system::error_code& error,
        std::size_t bytes_transferred
) {
    if(!error) {
            response_.consume(bytes_transferred);
                boost::asio::async_write(socket_, request_,
                    boost::bind(&asterisk::handle_write_request, this,
                        boost::asio::placeholders::error
        //, * to next read handler...
        ));
        }else{
            throw(boost::system::system_error(error));
        }
}

void handle_write_request(
    const boost::system::error_code& error
    //, memfunction func
) {
    if (!error) {
        boost::asio::async_read_until(socket_, response_, "\r\n",
                    boost::bind(
            //&asterisk::handle_read_login_attempt,
            func
            this,
                        boost::asio::placeholders::error,
                        boost::asio::placeholders::bytes_transferred));
        }else{
        throw(boost::system::system_error(error));
        }
}

Thank you,
Etienne


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net