Hi all,
I am learning boost library for the network programming and i read about boost bind and have some doubts in the following code.
boost::asio::async_read_until(socket_, buf, boost::regex("\r\n\r\n"),
boost::bind(&connection::handle_read, shared_from_this(),
ba::placeholders::error,
ba::placeholders::bytes_transferred));
here inside bind it has three arguments
(shared_from_this(),
ba::placeholders::error,
ba::placeholders::bytes_transferred)
but the member function "handle_read" inside the "connection" class has only two arguments as given below.
void handle_read(const boost::system::error_code& error,
size_t bytes_transferred) {
ba::async_write(socket_, ba::buffer(message_),
boost::bind(&connection::handle_write, shared_from_this(),
ba::placeholders::error,
ba::placeholders::bytes_transferred));
}
i dont understand why bind uses an extra argument shared_from_this(),i also want to know about the placeholders.
can any one please clarify on this .
with regards,
hari .