I want to print the message sent by the client. But in my function handleRead, when get the data from buffer and print it , nothing is print. I don't know how to do it.
void Network::start()
{
boost::asio::async_write(m_socket, boost::asio::buffer(m_message),
boost::bind(&Network::handleWrite,shared_from_this(),
boost::asio::placeholders::error));
}
void Network::handleWrite(const boost::system::error_code &error)
{
if (!error)
doRead();
else
std::cout << error.message() << std::endl;
}
void Network::handleRead(const boost::system::error_code &error)
{
if (!error) {
std::cout << m_buffer.data()<< std::endl;
doRead();
}
else
close();
}
void Network::doRead()
{
boost::asio::async_read(m_socket,
boost::asio::buffer(m_buffer),
boost::bind(&Network::handleRead,
shared_from_this(),
boost::asio::placeholders::error));
}