Asio buffers

From kangssu
Jump to: navigation, search

asio buffers

mutable_buffer -> MutableBufferSequence const_buffer -> constBufferSequence

vector<mutable_buffer> satisfies MutableBufferSequence

vector<const_buffer> satisfies ConstBufferSequence

it can express simply MutableBufferSequence, ConstBufferSequence using const_buffer_1 or mutable_buffer_1.


streambuf

#include <boost/asio.hpp>
#include <iostream>

using namespace boost;

int main() {
  asio::streambuf buf;
  std::ostream output(&buf);
  output << "hello2";
  std::istream input(&buf);
  std::string message1;
  std::getline(input, message1);
}
using io = boost::asio;
auto data = make_shared<io::streambuf>();
std::ostream(data.get()) << std::ifstream("main.cpp").rdbuf();
io::async_write(*sock, *data...);