我正在使用这段代码进行读取
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_是一个socket,max_length是一个值为1024的枚举类型,data_是具有长度等于max_length的字符数组。
但我想用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));
但是不起作用。我该怎么做?