[/
    Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)

    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

    Official repository: https://github.com/boostorg/beast
]

[section:using_io 网络通信]

该库使用的是 [@http://cplusplus.github.io/networking-ts/draft.pdf 网络技术规范]，当时预计最早要到 2023 年才有可能成为 C++ 官方标准的一部分。目前已有三个实现版本，它们在接口上有细微差异，但函数签名和类型声明基本相同：分别是 Boost.Asio、独立版 Asio 以及 networking-ts-impl。下表展示了在各个实现中，如何通过引入对应的头文件并使用合适的命名空间别名来声明 `io_context` 类型的变量：

[table 网络库的实现版本
[[Name][命名空间与头文件示例]]
[
    [__Asio__]
    [
```
        #include <boost/asio/io_context.hpp>
        namespace net = boost::asio;
        net::io_context ioc;
```
    ]
][
    [[@https://think-async.com/Asio/ Asio (Standalone)]]
    [
```
        #include <asio/io_context.hpp>
        namespace net = asio;
        net::io_context ioc;
```
    ]
][
    [[@https://github.com/chriskohlhoff/networking-ts-impl networking-ts-impl]]
    [
```
        #include <experimental/io_context>
        namespace net = std::experimental::net;
        net::io_context ioc;
```
    ]
]
]

本文档将上述三种实现统称为 [*网络库]（或简称为 ['networking]）。Boost.Asio 和 Asio 这两种网络库实现方式还提供了一些当前未纳入 C++ 标准提案但未来可能被加入的功能特性，例如：

* [@boost:/doc/html/boost_asio/reference/serial_port.html Serial ports]
* [@boost:/doc/html/boost_asio/reference/local__stream_protocol.html UNIX domain sockets]
* [@boost:/doc/html/boost_asio/reference/signal_set.html POSIX signals] (e.g. SIGINT, SIGABORT)
* [@boost:/doc/html/boost_asio/reference/ssl__stream.html TLS streams] (such as OpenSSL)

Boost.Beast 目前专门依赖于网络库的 Boost.Asio 实现（尽管未来可能会有所变化）。该库虽然提供了高性能的 HTTP 与 WebSocket 网络协议实现，但涉及域名解析（DNS 查询）、建立对外连接以及接受入站连接等通用任务时，仍需依赖网络库接口来完成。调用方需负责与网络库进行交互，将相关对象初始化至可供本库使用的正确状态。

在本文档、示例代码及具体实现中，使用 `net` 命名空间来限定网络库中的各类标识符。对于 Boost.Beast 而言，`net` 是 `boost::asio` 命名空间的别名。

为便于使用，本库提供了丰富的类型与算法集合。文档的此部分将对相关类型和算法进行说明，提供使用示例，同时包含网络库使用的复习与教程。

[heading 缩略语]

本文档假定读者已熟悉 __Asio__（使用 Beast 的必要前提）。全文中的示例代码与标识符均按以下声明处于有效状态为前提编写：

[snippet_core_1a]
[snippet_core_1b]

[include 1_refresher.qbk]
[include 2_streams.qbk]
[include 3_timeouts.qbk]
[include 4__layers.qbk]
[include 5_buffers.qbk]
[include 6_files.qbk]
[include 7_composed.qbk]
[include 9_ssl_tls_certificate.qbk]
[include 10_ssl_tls_shutdown.qbk]
[endsect]

[section:config 配置]
[include 8_conf_macros.qbk]
[endsect]
