我正在使用此代码阅读
socket_.async_read_some(boost::asio::buffer(data_, max_length),
boost::bind(&session::handle_read, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
这是为了写作
boost::asio::async_write(socket_,
boost::asio::buffer(data_, bytes_transferred),
boost::bind(&session::handle_write, this,
boost::asio::placeholders::error));
其中 socket_ 是套接字,max_length 是值为 1024 的枚举,data_ 是长度为 max_length 的 char 数组。
但我想用 streambuf 替换 char 数组缓冲区。我试过了
boost::asio::streambuf streamBuffer;
socket_.async_read_some(boost::asio::buffer(streamBuffer),
boost::bind(&session::handle_read, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
但不工作。我该怎么做 ?