So, the code I started with and which works (with important caveats below)
int reply_length = boost::asio::read(*m_socketptr, boost::asio::buffer((char*)reply, 6));
This works, I get a header, which I then decodes and tracks with another read that receives my message, and then I go back to the top and read another header. This binds my processor to 100%, so I want to replace the header read above with something like the following:
m_socketptr->async_read_some(boost::asio::buffer(m_data, 6), boost::bind(&CSListener::handleRead, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
or
boost::asio::async_read(*m_socketptr, boost::asio::buffer(m_data, 6), boost::bind(&CSListener::handleRead, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
In any case, I encode it, the handleRead method is never called. Help!
TIA
source
share