寻找一个boost :: asio(以及自己的提升)决定编写异步服务器.要存储传入的数据,我使用boost :: asio :: streambuf.我有一个问题.当我从客户端收到第二条消息后,我发现缓冲区中包含来自先前消息的数据.虽然我在输入缓冲区调用Consume方法.怎么了?
class tcp_connection
// Using shared_ptr and enable_shared_from_this
// because we want to keep the tcp_connection object alive
// as long as there is an operation that refers to it.
: public boost::enable_shared_from_this<tcp_connection>
{
...
boost::asio::streambuf receive_buffer;
boost::asio::io_service::strand strand;
}
...
void tcp_connection::receive()
{
// Read the response status line. The response_ streambuf will
// automatically grow to accommodate the entire line. The growth may be
// limited by passing a maximum size to …Run Code Online (Sandbox Code Playgroud)