详情见:http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/examples/cpp11_examples.html
或者:https://github.com/NearXdu/AsioLearn
1.示例
我们经常这样写代码:
size_t read_complete(boost::system::error_code, size_t bytes){ ... }
char buff[1024];
read(sock, boost::asio::buffer(buff), read_complete);
write(sock, buffer("echo\n"));
在example中,简单实现了一个buffer。
//
//This example demonstrates how to create reference counted buffers that can be used with socket read and write operations
#include <boost/asio.hpp>
#include <iostream>
#include <memory>
#include <utility>
#include <vector>
using namespace boost::asio;
using namespace boost::asio::ip;
class shared_const_buffer
{
public: