详情见: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:

本文介绍了Boost.Asio库中Buffer的概念,并通过示例详细讲解了如何使用streambuf进行网络编程,包括构造string、输出及写入到网络套接字的操作。
最低0.47元/天 解锁文章
599

被折叠的 条评论
为什么被折叠?



