1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-09-16 19:17:58 -05:00

Initial commit

This commit is contained in:
Crimson-Hawk
2024-03-05 16:42:40 +08:00
commit f1e4595ebf
39576 changed files with 7006612 additions and 0 deletions

View File

View File

View File

@@ -0,0 +1,2 @@
Checking patch include/boost/asio/detail/impl/socket_ops.ipp...
Applied patch include/boost/asio/detail/impl/socket_ops.ipp cleanly.

View File

@@ -0,0 +1,96 @@
* text=auto !eol svneol=native#text/plain
*.gitattributes text svneol=native#text/plain
# Scriptish formats
*.bat text svneol=native#text/plain
*.bsh text svneol=native#text/x-beanshell
*.cgi text svneol=native#text/plain
*.cmd text svneol=native#text/plain
*.js text svneol=native#text/javascript
*.php text svneol=native#text/x-php
*.pl text svneol=native#text/x-perl
*.pm text svneol=native#text/x-perl
*.py text svneol=native#text/x-python
*.sh eol=lf svneol=LF#text/x-sh
configure eol=lf svneol=LF#text/x-sh
# Image formats
*.bmp binary svneol=unset#image/bmp
*.gif binary svneol=unset#image/gif
*.ico binary svneol=unset#image/ico
*.jpeg binary svneol=unset#image/jpeg
*.jpg binary svneol=unset#image/jpeg
*.png binary svneol=unset#image/png
*.tif binary svneol=unset#image/tiff
*.tiff binary svneol=unset#image/tiff
*.svg text svneol=native#image/svg%2Bxml
# Data formats
*.pdf binary svneol=unset#application/pdf
*.avi binary svneol=unset#video/avi
*.doc binary svneol=unset#application/msword
*.dsp text svneol=crlf#text/plain
*.dsw text svneol=crlf#text/plain
*.eps binary svneol=unset#application/postscript
*.gz binary svneol=unset#application/gzip
*.mov binary svneol=unset#video/quicktime
*.mp3 binary svneol=unset#audio/mpeg
*.ppt binary svneol=unset#application/vnd.ms-powerpoint
*.ps binary svneol=unset#application/postscript
*.psd binary svneol=unset#application/photoshop
*.rdf binary svneol=unset#text/rdf
*.rss text svneol=unset#text/xml
*.rtf binary svneol=unset#text/rtf
*.sln text svneol=native#text/plain
*.swf binary svneol=unset#application/x-shockwave-flash
*.tgz binary svneol=unset#application/gzip
*.vcproj text svneol=native#text/xml
*.vcxproj text svneol=native#text/xml
*.vsprops text svneol=native#text/xml
*.wav binary svneol=unset#audio/wav
*.xls binary svneol=unset#application/vnd.ms-excel
*.zip binary svneol=unset#application/zip
# Text formats
.htaccess text svneol=native#text/plain
*.bbk text svneol=native#text/xml
*.cmake text svneol=native#text/plain
*.css text svneol=native#text/css
*.dtd text svneol=native#text/xml
*.htm text svneol=native#text/html
*.html text svneol=native#text/html
*.ini text svneol=native#text/plain
*.log text svneol=native#text/plain
*.mak text svneol=native#text/plain
*.qbk text svneol=native#text/plain
*.rst text svneol=native#text/plain
*.sql text svneol=native#text/x-sql
*.txt text svneol=native#text/plain
*.xhtml text svneol=native#text/xhtml%2Bxml
*.xml text svneol=native#text/xml
*.xsd text svneol=native#text/xml
*.xsl text svneol=native#text/xml
*.xslt text svneol=native#text/xml
*.xul text svneol=native#text/xul
*.yml text svneol=native#text/plain
boost-no-inspect text svneol=native#text/plain
CHANGES text svneol=native#text/plain
COPYING text svneol=native#text/plain
INSTALL text svneol=native#text/plain
Jamfile text svneol=native#text/plain
Jamroot text svneol=native#text/plain
Jamfile.v2 text svneol=native#text/plain
Jamrules text svneol=native#text/plain
Makefile* text svneol=native#text/plain
README text svneol=native#text/plain
TODO text svneol=native#text/plain
# Code formats
*.c text svneol=native#text/plain
*.cpp text svneol=native#text/plain
*.h text svneol=native#text/plain
*.hpp text svneol=native#text/plain
*.ipp text svneol=native#text/plain
*.tpp text svneol=native#text/plain
*.jam text svneol=native#text/plain
*.java text svneol=native#text/plain

View File

@@ -0,0 +1,7 @@
blank_issues_enabled: false
contact_links:
- name: Upstream repository located at https://github.com/chriskohlhoff/asio
url: https://github.com/chriskohlhoff/asio/issues
about: |
The source code in this repository is generated from upstream.
Please raise new issues there.

View File

@@ -0,0 +1,3 @@
The source code in this repository is generated from an upstream repository at https://github.com/chriskohlhoff/asio.
Please consider raising new pull requests at https://github.com/chriskohlhoff/asio/pulls.

View File

@@ -0,0 +1,26 @@
# Configuration for Move Issues - https://github.com/dessant/move-issues
# Delete the command comment when it contains no other content
deleteCommand: true
# Close the source issue after moving
closeSourceIssue: true
# Lock the source issue after moving
lockSourceIssue: true
# Mention issue and comment authors
mentionAuthors: true
# Preserve mentions in the issue content
keepContentMentions: false
# Move labels that also exist on the target repository
moveLabels: false
# Set custom aliases for targets
aliases:
upstream: chriskohlhoff/asio
# Repository to extend settings from
# _extends: repo

View File

@@ -0,0 +1,40 @@
# Generated by `boostdep --cmake asio`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_asio VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_asio INTERFACE)
add_library(Boost::asio ALIAS boost_asio)
target_include_directories(boost_asio INTERFACE include)
target_link_libraries(boost_asio
INTERFACE
Boost::align
Boost::array
Boost::assert
Boost::bind
Boost::chrono
Boost::config
Boost::core
Boost::coroutine
Boost::date_time
Boost::function
Boost::regex
Boost::smart_ptr
Boost::system
Boost::throw_exception
Boost::type_traits
Boost::utility
)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

View File

@@ -0,0 +1 @@
/html

View File

@@ -0,0 +1,141 @@
#
# Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
#
using quickbook ;
########################################################################
# Standalone HTML documentation
xml standalone_doc
:
asio.qbk
;
install images
:
overview/proactor.png
overview/sync_op.png
overview/async_op1.png
overview/async_op2.png
overview/model/async_agent_chain.png
overview/model/async_agent_model.png
overview/model/async_child_agent_chain.png
overview/model/async_op_init_complete.png
overview/model/async_op_model.png
overview/model/async_op_phases.png
overview/model/async_op_trivial_chain.png
overview/model/completion_token_model.png
overview/model/completion_token_transform.png
overview/model/higher_level_model.png
:
<location>html/boost_asio
;
local example-names = cpp03/allocation cpp03/buffers cpp03/chat cpp03/echo
cpp03/fork cpp03/http/client cpp03/http/server cpp03/http/server2
cpp03/http/server3 cpp03/http/server4 cpp03/icmp cpp03/invocation
cpp03/iostreams cpp03/local cpp03/multicast cpp03/nonblocking cpp03/porthopper
cpp03/serialization cpp03/services cpp03/socks4 cpp03/spawn cpp03/ssl
cpp03/timeouts cpp03/timers cpp03/windows cpp11/allocation cpp11/buffers
cpp11/chat cpp11/echo cpp11/executors cpp11/fork cpp11/futures
cpp11/handler_tracking cpp11/http/server cpp11/invocation cpp11/local
cpp11/multicast cpp11/nonblocking cpp11/operations cpp11/socks4 cpp11/ssl
cpp11/timeouts cpp11/timers cpp11/spawn cpp14/deferred cpp14/echo
cpp14/executors cpp14/iostreams cpp14/operations cpp14/parallel_group
cpp17/coroutines_ts cpp20/channels ;
for local l in $(example-names)
{
install ex_$(l) : [ glob ../example/$(l)/*.*pp ] : <location>html/boost_asio/example/$(l) ;
}
boostbook standalone
:
standalone_doc
:
<xsl:param>boost.root=../../../..
<xsl:param>chapter.autolabel=0
<xsl:param>chunk.section.depth=8
<xsl:param>chunk.first.sections=1
<xsl:param>toc.section.depth=2
<xsl:param>toc.max.depth=1
<xsl:param>generate.section.toc.level=1
<xsl:param>generate.toc="chapter nop section nop"
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/asio/doc/html
;
########################################################################
# HTML documentation for $(BOOST_ROOT)/doc/html
xml asio_doc
:
asio.qbk
;
explicit asio_doc ;
install asio_doc_images
:
overview/proactor.png
overview/sync_op.png
overview/async_op1.png
overview/async_op2.png
overview/model/async_agent_chain.png
overview/model/async_agent_model.png
overview/model/async_child_agent_chain.png
overview/model/async_op_init_complete.png
overview/model/async_op_model.png
overview/model/async_op_phases.png
overview/model/async_op_trivial_chain.png
overview/model/completion_token_model.png
overview/model/completion_token_transform.png
overview/model/higher_level_model.png
:
<location>$(BOOST_ROOT)/doc/html/boost_asio
;
explicit asio_doc_images ;
for local l in $(example-names)
{
install asio_ex_$(l) : [ glob ../example/$(l)/*.*pp ] : <location>$(BOOST_ROOT)/doc/html/boost_asio/example/$(l) ;
explicit asio_ex_$(l) ;
}
alias asio_examples : asio_ex_$(example-names) ;
explicit asio_examples ;
path-constant images_location : ../../../doc/html ;
boostbook asio
:
asio_doc
:
<name>../../../doc/html
<xsl:param>chapter.autolabel=0
<xsl:param>chunk.section.depth=8
<xsl:param>chunk.first.sections=1
<xsl:param>toc.section.depth=2
<xsl:param>toc.max.depth=1
<xsl:param>generate.section.toc.level=1
<xsl:param>generate.toc="chapter nop section nop"
<xsl:param>root.filename=boost_asio
<format>pdf:<xsl:param>img.src.path=$(images_location)/
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/asio/doc/html
:
<dependency>asio_doc_images
<dependency>asio_examples
;
explicit asio ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : asio ;
explicit boostrelease ;

View File

@@ -0,0 +1,142 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[library Boost.Asio
[quickbook 1.7]
[compatibility-mode 1.4]
[copyright 2003 - 2022 Christopher M. Kohlhoff]
[purpose Networking library]
[license
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])
]
[authors [Kohlhoff, Christopher]]
[category template]
[category generic]
]
[template mdash[] '''&mdash; ''']
[template hr[] [br]'''<phrase role="silver">'''[mdash]'''</phrase>'''[br]]
[template half_open_range[text] '''&#91;'''[text])]
[template indexterm1[id term1] '''<indexterm id="'''[id]'''"><primary>'''[term1]'''</primary></indexterm>''']
[template indexterm2[id term1 term2] '''<indexterm id="'''[id]'''"><primary>'''[term1]'''</primary><secondary>'''[term2]'''</secondary></indexterm>''']
[template inline_note[text] \[['Note:] [text] '''&mdash;'''['end note]\] ]
[template ticket[number]'''<ulink url="https://svn.boost.org/trac/boost/ticket/'''[number]'''">'''#[number]'''</ulink>''']
[template static[] '''<phrase role="silver">'''\[static\]'''</phrase>''']
[template constructor[] '''<phrase role="silver">'''\[constructor\]'''</phrase>''']
[template destructor[] '''<phrase role="silver">'''\[destructor\]'''</phrase>''']
[def __POSIX__ /POSIX/]
[def __Windows__ /Windows/]
[def __accept__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/accept.html `accept()`]]
[def __connect__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/connect.html `connect()`]]
[def __getpeername__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/getpeername.html `getpeername()`]]
[def __getsockname__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/getsockname.html `getsockname()`]]
[def __getsockopt__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html `getsockopt()`]]
[def __ioctl__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/ioctl.html `ioctl()`]]
[def __poll__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/poll.html `poll()`]]
[def __recvfrom__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html `recvfrom()`]]
[def __sendto__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/sendto.html `sendto()`]]
[def __setsockopt__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html `setsockopt()`]]
[def __shutdown__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/shutdown.html `shutdown()`]]
[def __socket__ [@http://www.opengroup.org/onlinepubs/9699919799/functions/socket.html `socket()`]]
[/=============================================================================]
Boost.Asio is a cross-platform C++ library for network and low-level I/O programming
that provides developers with a consistent asynchronous model using a modern
C++ approach.
[variablelist
[
[
[link boost_asio.overview Overview]
]
[
An overview of the features included in Boost.Asio, plus rationale and design information.
]
]
[
[
[link boost_asio.using Using, Building, and Configuring Boost.Asio]
]
[
How to use Boost.Asio in your applications. Includes information on
library dependencies and supported platforms.
]
]
[
[
[link boost_asio.tutorial Tutorial]
]
[
A tutorial that introduces the fundamental concepts required to use
Boost.Asio, and shows how to use Boost.Asio to develop simple client and
server programs.
]
]
[
[
[link boost_asio.examples Examples]
]
[
Examples that illustrate the use of Boost.Asio in more complex applications.
]
]
[
[
[link boost_asio.reference Reference]
]
[
Detailed class and function reference.
]
]
[
[
[link boost_asio.net_ts Networking TS Compatibility]
]
[
Description of changes to provide compatibility with the "C++ Extensions
for Networking" Technical Specification.
]
]
[
[
[link boost_asio.std_executors Proposed Standard Executors]
]
[
Description of Boost.Asio's support for the proposed standard executors
library.
]
]
[
[
[link boost_asio.history Revision History]
]
[
Log of Boost.Asio changes made in each Boost release.
]
]
[
[
[link boost_asio.index Index]
]
[
Book-style text index of Boost.Asio documentation.
]
]
]
[include overview.qbk]
[include using.qbk]
[include tutorial.qbk]
[include examples.qbk]
[include reference.qbk]
[include net_ts.qbk]
[include std_executors.qbk]
[include history.qbk]
[xinclude index.xml]

View File

@@ -0,0 +1,22 @@
#!/usr/bin/perl -w
# Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
use strict;
system("doxygen reference.dox");
chdir("xml");
system("xsltproc combine.xslt index.xml > all.xml");
chdir("..");
system("xsltproc reference.xsl xml/all.xml > reference.qbk");
system("rm -rf xml");
system("doxygen tutorial.dox");
chdir("xml");
system("xsltproc combine.xslt index.xml > all.xml");
chdir("..");
system("xsltproc tutorial.xsl xml/all.xml > tutorial.qbk");
system("rm -rf xml reference.tags");

View File

@@ -0,0 +1,649 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:examples Examples]
* [link boost_asio.examples.cpp03_examples C++03 Examples]: Illustrates the use of
Boost.Asio using only C++03 language and library features. Where necessary, the
examples make use of selected Boost C++ libraries.
* [link boost_asio.examples.cpp11_examples C++11 Examples]: Contains a limited set of
the C++03 Boost.Asio examples, updated to use only C++11 library and language
facilities. These examples do not make direct use of Boost C++ libraries.
* [link boost_asio.examples.cpp14_examples C++14 Examples]: Contains a limited set of
the C++03 Boost.Asio examples, updated to use only C++14 library and language
facilities. These examples do not make direct use of Boost C++ libraries.
* [link boost_asio.examples.cpp17_examples C++17 Examples]: Selected examples
illustrating C++17 usage in conjunction with Technical Specifications.
* [link boost_asio.examples.cpp20_examples C++20 Examples]: Selected examples
using C++20 language features.
[section:cpp03_examples C++03 Examples]
[heading Allocation]
This example shows how to customise the allocation of memory associated with
asynchronous operations.
* [@boost_asio/example/cpp03/allocation/server.cpp]
[heading Buffers]
This example demonstrates how to create reference counted buffers that can be
used with socket read and write operations.
* [@boost_asio/example/cpp03/buffers/reference_counted.cpp]
[heading Chat]
This example implements a chat server and client. The programs use a custom
protocol with a fixed length message header and variable length message body.
* [@boost_asio/example/cpp03/chat/chat_message.hpp]
* [@boost_asio/example/cpp03/chat/chat_client.cpp]
* [@boost_asio/example/cpp03/chat/chat_server.cpp]
The following POSIX-specific chat client demonstrates how to use the
[link boost_asio.reference.posix__stream_descriptor posix::stream_descriptor] class to
perform console input and output.
* [@boost_asio/example/cpp03/chat/posix_chat_client.cpp]
[heading Echo]
A collection of simple clients and servers, showing the use of both synchronous
and asynchronous operations.
* [@boost_asio/example/cpp03/echo/async_tcp_echo_server.cpp]
* [@boost_asio/example/cpp03/echo/async_udp_echo_server.cpp]
* [@boost_asio/example/cpp03/echo/blocking_tcp_echo_client.cpp]
* [@boost_asio/example/cpp03/echo/blocking_tcp_echo_server.cpp]
* [@boost_asio/example/cpp03/echo/blocking_udp_echo_client.cpp]
* [@boost_asio/example/cpp03/echo/blocking_udp_echo_server.cpp]
[heading Fork]
These POSIX-specific examples show how to use Boost.Asio in conjunction with the
`fork()` system call. The first example illustrates the steps required to start
a daemon process:
* [@boost_asio/example/cpp03/fork/daemon.cpp]
The second example demonstrates how it is possible to fork a process from
within a completion handler.
* [@boost_asio/example/cpp03/fork/process_per_connection.cpp]
[heading HTTP Client]
Example programs implementing simple HTTP 1.0 clients. These examples show how
to use the [link boost_asio.reference.read_until read_until] and [link
boost_asio.reference.async_read_until async_read_until] functions.
* [@boost_asio/example/cpp03/http/client/sync_client.cpp]
* [@boost_asio/example/cpp03/http/client/async_client.cpp]
[heading HTTP Server]
This example illustrates the use of asio in a simple single-threaded server
implementation of HTTP 1.0. It demonstrates how to perform a clean shutdown by
cancelling all outstanding asynchronous operations.
* [@boost_asio/example/cpp03/http/server/connection.cpp]
* [@boost_asio/example/cpp03/http/server/connection.hpp]
* [@boost_asio/example/cpp03/http/server/connection_manager.cpp]
* [@boost_asio/example/cpp03/http/server/connection_manager.hpp]
* [@boost_asio/example/cpp03/http/server/header.hpp]
* [@boost_asio/example/cpp03/http/server/main.cpp]
* [@boost_asio/example/cpp03/http/server/mime_types.cpp]
* [@boost_asio/example/cpp03/http/server/mime_types.hpp]
* [@boost_asio/example/cpp03/http/server/reply.cpp]
* [@boost_asio/example/cpp03/http/server/reply.hpp]
* [@boost_asio/example/cpp03/http/server/request.hpp]
* [@boost_asio/example/cpp03/http/server/request_handler.cpp]
* [@boost_asio/example/cpp03/http/server/request_handler.hpp]
* [@boost_asio/example/cpp03/http/server/request_parser.cpp]
* [@boost_asio/example/cpp03/http/server/request_parser.hpp]
* [@boost_asio/example/cpp03/http/server/server.cpp]
* [@boost_asio/example/cpp03/http/server/server.hpp]
[heading HTTP Server 2]
An HTTP server using an io_context-per-CPU design.
* [@boost_asio/example/cpp03/http/server2/connection.cpp]
* [@boost_asio/example/cpp03/http/server2/connection.hpp]
* [@boost_asio/example/cpp03/http/server2/header.hpp]
* [@boost_asio/example/cpp03/http/server2/io_context_pool.cpp]
* [@boost_asio/example/cpp03/http/server2/io_context_pool.hpp]
* [@boost_asio/example/cpp03/http/server2/main.cpp]
* [@boost_asio/example/cpp03/http/server2/mime_types.cpp]
* [@boost_asio/example/cpp03/http/server2/mime_types.hpp]
* [@boost_asio/example/cpp03/http/server2/reply.cpp]
* [@boost_asio/example/cpp03/http/server2/reply.hpp]
* [@boost_asio/example/cpp03/http/server2/request.hpp]
* [@boost_asio/example/cpp03/http/server2/request_handler.cpp]
* [@boost_asio/example/cpp03/http/server2/request_handler.hpp]
* [@boost_asio/example/cpp03/http/server2/request_parser.cpp]
* [@boost_asio/example/cpp03/http/server2/request_parser.hpp]
* [@boost_asio/example/cpp03/http/server2/server.cpp]
* [@boost_asio/example/cpp03/http/server2/server.hpp]
[heading HTTP Server 3]
An HTTP server using a single io_context and a thread pool calling `io_context::run()`.
* [@boost_asio/example/cpp03/http/server3/connection.cpp]
* [@boost_asio/example/cpp03/http/server3/connection.hpp]
* [@boost_asio/example/cpp03/http/server3/header.hpp]
* [@boost_asio/example/cpp03/http/server3/main.cpp]
* [@boost_asio/example/cpp03/http/server3/mime_types.cpp]
* [@boost_asio/example/cpp03/http/server3/mime_types.hpp]
* [@boost_asio/example/cpp03/http/server3/reply.cpp]
* [@boost_asio/example/cpp03/http/server3/reply.hpp]
* [@boost_asio/example/cpp03/http/server3/request.hpp]
* [@boost_asio/example/cpp03/http/server3/request_handler.cpp]
* [@boost_asio/example/cpp03/http/server3/request_handler.hpp]
* [@boost_asio/example/cpp03/http/server3/request_parser.cpp]
* [@boost_asio/example/cpp03/http/server3/request_parser.hpp]
* [@boost_asio/example/cpp03/http/server3/server.cpp]
* [@boost_asio/example/cpp03/http/server3/server.hpp]
[heading HTTP Server 4]
A single-threaded HTTP server implemented using stackless coroutines.
* [@boost_asio/example/cpp03/http/server4/file_handler.cpp]
* [@boost_asio/example/cpp03/http/server4/file_handler.hpp]
* [@boost_asio/example/cpp03/http/server4/header.hpp]
* [@boost_asio/example/cpp03/http/server4/main.cpp]
* [@boost_asio/example/cpp03/http/server4/mime_types.cpp]
* [@boost_asio/example/cpp03/http/server4/mime_types.hpp]
* [@boost_asio/example/cpp03/http/server4/reply.cpp]
* [@boost_asio/example/cpp03/http/server4/reply.hpp]
* [@boost_asio/example/cpp03/http/server4/request.hpp]
* [@boost_asio/example/cpp03/http/server4/request_parser.cpp]
* [@boost_asio/example/cpp03/http/server4/request_parser.hpp]
* [@boost_asio/example/cpp03/http/server4/server.cpp]
* [@boost_asio/example/cpp03/http/server4/server.hpp]
[heading ICMP]
This example shows how to use raw sockets with ICMP to ping a remote host.
* [@boost_asio/example/cpp03/icmp/ping.cpp]
* [@boost_asio/example/cpp03/icmp/ipv4_header.hpp]
* [@boost_asio/example/cpp03/icmp/icmp_header.hpp]
[heading Invocation]
This example shows how to customise handler invocation. Completion handlers are
added to a priority queue rather than executed immediately.
* [@boost_asio/example/cpp03/invocation/prioritised_handlers.cpp]
[heading Iostreams]
Two examples showing how to use [link boost_asio.reference.ip__tcp.iostream
ip::tcp::iostream].
* [@boost_asio/example/cpp03/iostreams/daytime_client.cpp]
* [@boost_asio/example/cpp03/iostreams/daytime_server.cpp]
* [@boost_asio/example/cpp03/iostreams/http_client.cpp]
[heading Multicast]
An example showing the use of multicast to transmit packets to a group of
subscribers.
* [@boost_asio/example/cpp03/multicast/receiver.cpp]
* [@boost_asio/example/cpp03/multicast/sender.cpp]
[heading Serialization]
This example shows how Boost.Serialization can be used with asio to encode and
decode structures for transmission over a socket.
* [@boost_asio/example/cpp03/serialization/client.cpp]
* [@boost_asio/example/cpp03/serialization/connection.hpp]
* [@boost_asio/example/cpp03/serialization/server.cpp]
* [@boost_asio/example/cpp03/serialization/stock.hpp]
[heading Services]
This example demonstrates how to integrate custom functionality (in this case,
for logging) into asio's [link boost_asio.reference.io_context io_context], and
how to use a custom service with [link
boost_asio.reference.basic_stream_socket basic_stream_socket<>].
* [@boost_asio/example/cpp03/services/basic_logger.hpp]
* [@boost_asio/example/cpp03/services/daytime_client.cpp]
* [@boost_asio/example/cpp03/services/logger.hpp]
* [@boost_asio/example/cpp03/services/logger_service.cpp]
* [@boost_asio/example/cpp03/services/logger_service.hpp]
* [@boost_asio/example/cpp03/services/stream_socket_service.hpp]
[heading SOCKS 4]
Example client program implementing the SOCKS 4 protocol for communication via
a proxy.
* [@boost_asio/example/cpp03/socks4/sync_client.cpp]
* [@boost_asio/example/cpp03/socks4/socks4.hpp]
[heading SSL]
Example client and server programs showing the use of the [link
boost_asio.reference.ssl__stream ssl::stream<>] template with asynchronous operations.
* [@boost_asio/example/cpp03/ssl/client.cpp]
* [@boost_asio/example/cpp03/ssl/server.cpp]
[heading Timeouts]
A collection of examples showing how to cancel long running asynchronous
operations after a period of time.
* [@boost_asio/example/cpp03/timeouts/async_tcp_client.cpp]
* [@boost_asio/example/cpp03/timeouts/blocking_tcp_client.cpp]
* [@boost_asio/example/cpp03/timeouts/blocking_token_tcp_client.cpp]
* [@boost_asio/example/cpp03/timeouts/blocking_udp_client.cpp]
* [@boost_asio/example/cpp03/timeouts/server.cpp]
[heading Timers]
Example showing how to customise basic_waitable_timer using a different clock type.
* [@boost_asio/example/cpp03/timers/time_t_timer.cpp]
[heading Porthopper]
Example illustrating mixed synchronous and asynchronous operations, and how to
use Boost.Lambda with Boost.Asio.
* [@boost_asio/example/cpp03/porthopper/protocol.hpp]
* [@boost_asio/example/cpp03/porthopper/client.cpp]
* [@boost_asio/example/cpp03/porthopper/server.cpp]
[heading Nonblocking]
Example demonstrating reactor-style operations for integrating a third-party
library that wants to perform the I/O operations itself.
* [@boost_asio/example/cpp03/nonblocking/third_party_lib.cpp]
[heading Spawn]
Example of using the boost::asio::spawn() function, a wrapper around the
[@http://www.boost.org/doc/libs/release/libs/coroutine/index.html Boost.Coroutine]
library, to implement a chain of asynchronous operations using stackful
coroutines.
* [@boost_asio/example/cpp03/spawn/echo_server.cpp]
[heading UNIX Domain Sockets]
Examples showing how to use UNIX domain (local) sockets.
* [@boost_asio/example/cpp03/local/connect_pair.cpp]
* [@boost_asio/example/cpp03/local/iostream_client.cpp]
* [@boost_asio/example/cpp03/local/stream_server.cpp]
* [@boost_asio/example/cpp03/local/stream_client.cpp]
[heading Windows]
An example showing how to use the Windows-specific function `TransmitFile`
with Boost.Asio.
* [@boost_asio/example/cpp03/windows/transmit_file.cpp]
[endsect]
[section:cpp11_examples C++11 Examples]
[heading Allocation]
This example shows how to customise the allocation of memory associated with
asynchronous operations.
* [@boost_asio/example/cpp11/allocation/server.cpp]
[heading Buffers]
This example demonstrates how to create reference counted buffers that can be
used with socket read and write operations.
* [@boost_asio/example/cpp11/buffers/reference_counted.cpp]
[heading Chat]
This example implements a chat server and client. The programs use a custom
protocol with a fixed length message header and variable length message body.
* [@boost_asio/example/cpp11/chat/chat_message.hpp]
* [@boost_asio/example/cpp11/chat/chat_client.cpp]
* [@boost_asio/example/cpp11/chat/chat_server.cpp]
[heading Echo]
A collection of simple clients and servers, showing the use of both synchronous
and asynchronous operations.
* [@boost_asio/example/cpp11/echo/async_tcp_echo_server.cpp]
* [@boost_asio/example/cpp11/echo/async_udp_echo_server.cpp]
* [@boost_asio/example/cpp11/echo/blocking_tcp_echo_client.cpp]
* [@boost_asio/example/cpp11/echo/blocking_tcp_echo_server.cpp]
* [@boost_asio/example/cpp11/echo/blocking_udp_echo_client.cpp]
* [@boost_asio/example/cpp11/echo/blocking_udp_echo_server.cpp]
[heading Fork]
These POSIX-specific examples show how to use Boost.Asio in conjunction with the
`fork()` system call. The first example illustrates the steps required to start
a daemon process:
* [@boost_asio/example/cpp11/fork/daemon.cpp]
The second example demonstrates how it is possible to fork a process from
within a completion handler.
* [@boost_asio/example/cpp11/fork/process_per_connection.cpp]
[heading Futures]
This example demonstrates how to use std::future in conjunction with
Boost.Asio's asynchronous operations.
* [@boost_asio/example/cpp11/futures/daytime_client.cpp]
[heading Handler Tracking]
This example header file shows how to implement custom handler tracking.
* [@boost_asio/example/cpp11/handler_tracking/custom_tracking.hpp]
This example program shows how to include source location information in
the handler tracking output.
* [@boost_asio/example/cpp11/handler_tracking/async_tcp_echo_server.cpp]
[heading HTTP Server]
This example illustrates the use of asio in a simple single-threaded server
implementation of HTTP 1.0. It demonstrates how to perform a clean shutdown by
cancelling all outstanding asynchronous operations.
* [@boost_asio/example/cpp11/http/server/connection.cpp]
* [@boost_asio/example/cpp11/http/server/connection.hpp]
* [@boost_asio/example/cpp11/http/server/connection_manager.cpp]
* [@boost_asio/example/cpp11/http/server/connection_manager.hpp]
* [@boost_asio/example/cpp11/http/server/header.hpp]
* [@boost_asio/example/cpp11/http/server/main.cpp]
* [@boost_asio/example/cpp11/http/server/mime_types.cpp]
* [@boost_asio/example/cpp11/http/server/mime_types.hpp]
* [@boost_asio/example/cpp11/http/server/reply.cpp]
* [@boost_asio/example/cpp11/http/server/reply.hpp]
* [@boost_asio/example/cpp11/http/server/request.hpp]
* [@boost_asio/example/cpp11/http/server/request_handler.cpp]
* [@boost_asio/example/cpp11/http/server/request_handler.hpp]
* [@boost_asio/example/cpp11/http/server/request_parser.cpp]
* [@boost_asio/example/cpp11/http/server/request_parser.hpp]
* [@boost_asio/example/cpp11/http/server/server.cpp]
* [@boost_asio/example/cpp11/http/server/server.hpp]
[heading Multicast]
An example showing the use of multicast to transmit packets to a group of
subscribers.
* [@boost_asio/example/cpp11/multicast/receiver.cpp]
* [@boost_asio/example/cpp11/multicast/sender.cpp]
[heading Nonblocking]
Example demonstrating reactor-style operations for integrating a third-party
library that wants to perform the I/O operations itself.
* [@boost_asio/example/cpp11/nonblocking/third_party_lib.cpp]
[heading Operations]
Examples showing how to implement composed asynchronous operations as reusable library functions.
* [@boost_asio/example/cpp11/operations/composed_1.cpp]
* [@boost_asio/example/cpp11/operations/composed_2.cpp]
* [@boost_asio/example/cpp11/operations/composed_3.cpp]
* [@boost_asio/example/cpp11/operations/composed_4.cpp]
* [@boost_asio/example/cpp11/operations/composed_5.cpp]
* [@boost_asio/example/cpp11/operations/composed_6.cpp]
* [@boost_asio/example/cpp11/operations/composed_7.cpp]
* [@boost_asio/example/cpp11/operations/composed_8.cpp]
[heading SOCKS 4]
Example client program implementing the SOCKS 4 protocol for communication via
a proxy.
* [@boost_asio/example/cpp11/socks4/sync_client.cpp]
* [@boost_asio/example/cpp11/socks4/socks4.hpp]
[heading Spawn]
Example of using the boost::asio::spawn() function, a wrapper around the
[@http://www.boost.org/doc/libs/release/libs/coroutine/index.html Boost.Coroutine]
library, to implement a chain of asynchronous operations using stackful
coroutines.
* [@boost_asio/example/cpp11/spawn/echo_server.cpp]
[heading SSL]
Example client and server programs showing the use of the [link
boost_asio.reference.ssl__stream ssl::stream<>] template with asynchronous operations.
* [@boost_asio/example/cpp11/ssl/client.cpp]
* [@boost_asio/example/cpp11/ssl/server.cpp]
[heading Timeouts]
A collection of examples showing how to cancel long running asynchronous
operations after a period of time.
* [@boost_asio/example/cpp11/timeouts/async_tcp_client.cpp]
* [@boost_asio/example/cpp11/timeouts/blocking_tcp_client.cpp]
* [@boost_asio/example/cpp11/timeouts/blocking_token_tcp_client.cpp]
* [@boost_asio/example/cpp11/timeouts/blocking_udp_client.cpp]
* [@boost_asio/example/cpp11/timeouts/server.cpp]
[heading Timers]
Example showing how to customise basic_waitable_timer using a different clock type.
* [@boost_asio/example/cpp11/timers/time_t_timer.cpp]
[heading UNIX Domain Sockets]
Examples showing how to use UNIX domain (local) sockets.
* [@boost_asio/example/cpp11/local/connect_pair.cpp]
* [@boost_asio/example/cpp11/local/iostream_client.cpp]
* [@boost_asio/example/cpp11/local/stream_server.cpp]
* [@boost_asio/example/cpp11/local/stream_client.cpp]
* [@boost_asio/example/cpp11/local/fd_passing_stream_server.cpp]
* [@boost_asio/example/cpp11/local/fd_passing_stream_client.cpp]
[endsect]
[section:cpp14_examples C++14 Examples]
[heading Deferred]
Examples showing how to use the [link boost_asio.reference.experimental__deferred
`experimental::deferred`] completion token.
* [@boost_asio/example/cpp14/deferred/deferred_1.cpp]
* [@boost_asio/example/cpp14/deferred/deferred_2.cpp]
* [@boost_asio/example/cpp14/deferred/deferred_3.cpp]
* [@boost_asio/example/cpp14/deferred/deferred_4.cpp]
* [@boost_asio/example/cpp14/deferred/deferred_5.cpp]
* [@boost_asio/example/cpp14/deferred/deferred_6.cpp]
* [@boost_asio/example/cpp14/deferred/deferred_7.cpp]
[heading Echo]
A collection of simple clients and servers, showing the use of both synchronous
and asynchronous operations.
* [@boost_asio/example/cpp14/echo/async_tcp_echo_server.cpp]
* [@boost_asio/example/cpp14/echo/async_udp_echo_server.cpp]
* [@boost_asio/example/cpp14/echo/blocking_tcp_echo_client.cpp]
* [@boost_asio/example/cpp14/echo/blocking_tcp_echo_server.cpp]
* [@boost_asio/example/cpp14/echo/blocking_udp_echo_client.cpp]
* [@boost_asio/example/cpp14/echo/blocking_udp_echo_server.cpp]
[heading Executors]
Examples showing how to use the executor-related facilities.
* [@boost_asio/example/cpp14/executors/actor.cpp]
* [@boost_asio/example/cpp14/executors/async_1.cpp]
* [@boost_asio/example/cpp14/executors/async_2.cpp]
* [@boost_asio/example/cpp14/executors/bank_account_1.cpp]
* [@boost_asio/example/cpp14/executors/bank_account_2.cpp]
* [@boost_asio/example/cpp14/executors/fork_join.cpp]
* [@boost_asio/example/cpp14/executors/pipeline.cpp]
* [@boost_asio/example/cpp14/executors/priority_scheduler.cpp]
[heading Iostreams]
Two examples showing how to use [link boost_asio.reference.ip__tcp.iostream
ip::tcp::iostream].
* [@boost_asio/example/cpp14/iostreams/http_client.cpp]
[heading Operations]
Examples showing how to implement composed asynchronous operations as reusable library functions.
* [@boost_asio/example/cpp14/operations/composed_1.cpp]
* [@boost_asio/example/cpp14/operations/composed_2.cpp]
* [@boost_asio/example/cpp14/operations/composed_3.cpp]
* [@boost_asio/example/cpp14/operations/composed_4.cpp]
* [@boost_asio/example/cpp14/operations/composed_5.cpp]
* [@boost_asio/example/cpp14/operations/composed_6.cpp]
* [@boost_asio/example/cpp14/operations/composed_7.cpp]
* [@boost_asio/example/cpp14/operations/composed_8.cpp]
Examples showing how to expose callback-based APIs as asynchronous operations.
* [@boost_asio/example/cpp14/operations/callback_wrapper.cpp]
* [@boost_asio/example/cpp14/operations/c_callback_wrapper.cpp]
[heading Parallel Groups]
Examples showing how to use the [link
boost_asio.reference.experimental__make_parallel_group
`experimental::make_parallel_group`] operation.
* [@boost_asio/example/cpp14/parallel_group/parallel_sort.cpp]
* [@boost_asio/example/cpp14/parallel_group/wait_for_all.cpp]
* [@boost_asio/example/cpp14/parallel_group/wait_for_one.cpp]
* [@boost_asio/example/cpp14/parallel_group/wait_for_one_error.cpp]
* [@boost_asio/example/cpp14/parallel_group/wait_for_one_success.cpp]
[endsect]
[section:cpp17_examples C++17 Examples]
[heading Coroutines TS Support]
Examples showing how to implement a chain of asynchronous operations using the
Coroutines TS.
* [@boost_asio/example/cpp17/coroutines_ts/echo_server.cpp]
* [@boost_asio/example/cpp17/coroutines_ts/refactored_echo_server.cpp]
* [@boost_asio/example/cpp17/coroutines_ts/chat_server.cpp]
* [@boost_asio/example/cpp17/coroutines_ts/range_based_for.cpp]
[endsect]
[section:cpp20_examples C++20 Examples]
[heading Channels]
Example showing how to use a channel in conjunction with C++20 coroutines.
* [@boost_asio/example/cpp20/channels/throttling_proxy.cpp]
[endsect]
[endsect]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "../../../tools/boostbook/dtd/boostbook.dtd">
<!--
Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
-->
<section id="boost_asio.index">
<index/>
</section>

View File

@@ -0,0 +1,14 @@
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
//
/**
\page asynchronous_operation asynchronous operation
*/
/**
\page completion_token completion token
*/

View File

@@ -0,0 +1,479 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:net_ts Networking TS compatibility]
Boost.Asio now provides the interfaces and functionality specified by the "C++
Extensions for Networking" Technical Specification. In addition to access via
the usual Boost.Asio header files, this functionality may be accessed through special
headers that correspond to the header files defined in the TS. These are listed
in the table below:
[table
[[Networking TS header][Boost.Asio header]]
[[`#include <buffer>`][`#include <boost/asio/ts/buffer.hpp>`]]
[[`#include <executor>`][`#include <boost/asio/ts/executor.hpp>`]]
[[`#include <internet>`][`#include <boost/asio/ts/internet.hpp>`]]
[[`#include <io_context>`][`#include <boost/asio/ts/io_context.hpp>`]]
[[`#include <net>`][`#include <boost/asio/ts/net.hpp>`]]
[[`#include <netfwd>`][`#include <boost/asio/ts/netfwd.hpp>`]]
[[`#include <socket>`][`#include <boost/asio/ts/socket.hpp>`]]
[[`#include <timer>`][`#include <boost/asio/ts/timer.hpp>`]]
]
In some cases the new Networking TS compatible interfaces supersede older Boost.Asio
facilities. In these cases the older interfaces have been deprecated. The table
below shows the new Networking TS interfaces and the facilities they replace:
[table
[[New interface][Old interface][Notes]]
[
[[link boost_asio.reference.io_context `io_context`]]
[[link boost_asio.reference.io_service `io_service`]]
[The name `io_service` is retained as a typedef.]
]
[
[[link boost_asio.reference.dispatch `dispatch`]]
[[link boost_asio.reference.io_context.dispatch `io_service::dispatch`]]
[The `dispatch` free function can be used to submit functions to any [link
boost_asio.reference.Executor1 Executor] or [link boost_asio.reference.ExecutionContext
ExecutionContext].]
]
[
[[link boost_asio.reference.post `post`]]
[[link boost_asio.reference.io_context.post `io_service::post`]]
[The `post` free function can be used to submit functions to any [link
boost_asio.reference.Executor1 Executor] or [link boost_asio.reference.ExecutionContext
ExecutionContext].]
]
[
[[link boost_asio.reference.defer `defer`]]
[[link boost_asio.reference.io_context.post `io_service::post`] when the [link
boost_asio.reference.asio_handler_is_continuation `asio_handler_is_continuation`]
hook returns true]
[The `defer` free function can be used to submit functions to any [link
boost_asio.reference.Executor1 Executor] or [link boost_asio.reference.ExecutionContext
ExecutionContext].]
]
[
[[link boost_asio.reference.io_context.poll `io_context::poll`]]
[[link boost_asio.reference.io_context.poll `io_service::poll`] overload that
takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.io_context.poll_one `io_context::poll_one`]]
[[link boost_asio.reference.io_context.poll_one `io_service::poll_one`] overload
that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.io_context.run `io_context::run`]]
[[link boost_asio.reference.io_context.run `io_service::run`] overload that takes
`error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.io_context.run_one `io_context::run_one`]]
[[link boost_asio.reference.io_context.run_one `io_service::run_one`] overload
that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.io_context.run_for `io_context::run_for`],
[link boost_asio.reference.io_context.run_until `io_context::run_until`],
[link boost_asio.reference.io_context.run_one_for `io_context::run_one_for`], and
[link boost_asio.reference.io_context.run_one_until `io_context::run_one_until`]]
[]
[These functions add the ability to run an `io_context` for a limited time.]
]
[
[[link boost_asio.reference.io_context.restart `io_context::restart`]]
[[link boost_asio.reference.io_context.reset `io_service::reset`]]
[]
]
[
[[link boost_asio.reference.io_context.io_context `io_context`] constructor
`concurrency_hint` parameter is type `int`]
[[link boost_asio.reference.io_context.io_context `io_context`] constructor
`concurrency_hint` parameter is type `std::size_t`]
[The old constructor has not been retained as a deprecated overload.]
]
[
[[link boost_asio.reference.execution_context `execution_context`], [link
boost_asio.reference.execution_context__service `execution_context::service`],
and [link boost_asio.reference.execution_context__id `execution_context::id`]]
[[link boost_asio.reference.io_context `io_service`], [link
boost_asio.reference.io_context__service `io_service::service`], and [link
boost_asio.reference.execution_context__id `io_service::id`]]
[The service-related functionality has been moved to the
`execution_context` base class. This may also be used as a base for
creating custom execution contexts.]
]
[
[[link boost_asio.reference.execution_context.make_service `make_service`]]
[[link boost_asio.reference.execution_context.add_service `add_service`]]
[]
]
[
[[link boost_asio.reference.strand `strand`]]
[[link boost_asio.reference.io_context__strand `io_service::strand`]]
[This template works with any valid executor, and is itself a valid
executor.]
]
[
[[link boost_asio.reference.executor_work_guard `executor_work_guard`] and [link
boost_asio.reference.make_work_guard `make_work_guard`]]
[[link boost_asio.reference.io_context__work `io_service::work`]]
[Work tracking is now covered by the [link boost_asio.reference.Executor1
Executor] requirements. These templates work with any valid executor.]
]
[
[[link boost_asio.reference.executor_binder `executor_binder`] and [link
boost_asio.reference.bind_executor `bind_executor`]]
[[link boost_asio.reference.io_context.wrap `io_service::wrap`] and
[link boost_asio.reference.io_context__strand.wrap `io_service::strand::wrap`]]
[These templates work with any valid executor.]
]
[
[[link boost_asio.reference.async_result `async_result`] with `CompletionToken`
and `Signature` template parameters]
[`handler_type` and single parameter `async_result`]
[The `async_result` trait is now the single point of customisation for
asynchronous operation completion handlers and return type.]
]
[
[[link boost_asio.reference.associated_executor `associated_executor`] and [link
boost_asio.reference.get_associated_executor `get_associated_executor`]]
[[link boost_asio.reference.asio_handler_invoke `asio_handler_invoke`]]
[The handler invocation hook has been replaced by the new [link
boost_asio.reference.Executor1 Executor] requirements and the associated executor
traits.]
]
[
[[link boost_asio.reference.associated_allocator `associated_allocator`] and
[link boost_asio.reference.get_associated_allocator `get_associated_allocator`]]
[[link boost_asio.reference.asio_handler_allocate `asio_handler_allocate`] and
[link boost_asio.reference.asio_handler_deallocate `asio_handler_deallocate`]]
[The handler allocation hooks have been replaced by the standard Allocator
requirements and the associated allocator traits.]
]
[
[[link boost_asio.reference.const_buffer.data `const_buffer::data`] and [link
boost_asio.reference.mutable_buffer.data `mutable_buffer::data`]]
[[link boost_asio.reference.buffer_cast `buffer_cast`]]
[]
]
[
[[link boost_asio.reference.const_buffer.size `const_buffer::size`] and [link
boost_asio.reference.mutable_buffer.size `mutable_buffer::size`]]
[[link boost_asio.reference.buffer_size `buffer_size`] for single buffers]
[`buffer_size` is not deprecated for single buffers as `const_buffer` and
`mutable_buffer` now satisfy the buffer sequence requirements]
]
[
[[link boost_asio.reference.const_buffer `const_buffer`]]
[[link boost_asio.reference.const_buffers_1 `const_buffers_1`]]
[The [link boost_asio.reference.ConstBufferSequence ConstBufferSequence]
requirements have been modified such that `const_buffer` now satisfies
them.]
]
[
[[link boost_asio.reference.mutable_buffer `mutable_buffer`]]
[[link boost_asio.reference.mutable_buffers_1 `mutable_buffers_1`]]
[The [link boost_asio.reference.MutableBufferSequence MutableBufferSequence]
requirements have been modified such that `mutable_buffer` now satisfies
them.]
]
[
[[link boost_asio.reference.basic_socket.get_executor
`basic_socket::get_executor`] (and corresponding member for I/O objects
such as timers, serial ports, etc.)]
[[link boost_asio.reference.basic_io_object.get_io_service
`basic_io_object::get_io_service`]]
[Use `get_executor().context()` to obtain the associated `io_context`.]
]
[
[[link boost_asio.reference.socket_base.max_listen_connections
`socket_base::max_listen_connections`]]
[[link boost_asio.reference.socket_base.max_connections
`socket_base::max_connections`]]
[]
]
[
[[link boost_asio.reference.socket_base.wait_type `socket_base::wait_type`],
[link boost_asio.reference.basic_socket.wait `basic_socket::wait`], [link
boost_asio.reference.basic_socket.async_wait `basic_socket::async_wait`], [link
boost_asio.reference.basic_socket_acceptor.wait `basic_socket_acceptor::wait`],
and [link boost_asio.reference.basic_socket_acceptor.async_wait
`basic_socket_acceptor::async_wait`]]
[[link boost_asio.reference.null_buffers `null_buffers`]]
[Operations for reactive I/O.]
]
[
[[link boost_asio.reference.basic_socket_acceptor.accept
`basic_socket_acceptor::accept`] returns a socket]
[[link boost_asio.reference.basic_socket_acceptor.accept
`basic_socket_acceptor::accept`] takes a socket by reference]
[Uses move support so requires C++11 or later. To accept a connection into
a socket object on a different `io_context`, pass the destination context
to `accept`.]
]
[
[[link boost_asio.reference.basic_socket_acceptor.async_accept
`basic_socket_acceptor::async_accept`] passes socket to handler]
[[link boost_asio.reference.basic_socket_acceptor.async_accept
`basic_socket_acceptor::async_accept`] takes a socket by reference]
[Uses move support so requires C++11 or later. To accept a connection into
a socket object on a different `io_context`, pass the destination context
to `async_accept`.]
]
[
[[link boost_asio.reference.connect `connect`] overloads that take a range]
[[link boost_asio.reference.connect `connect`] overloads that take a single
iterator]
[The [link boost_asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] function now returns a range. When the
`resolve` function's result is passed directly to `connect`, the range
overload will be selected.]
]
[
[[link boost_asio.reference.async_connect `async_connect`] overloads that take a
range]
[[link boost_asio.reference.async_connect `async_connect`] overloads that take a
single iterator]
[The [link boost_asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] function now returns a range. When the
`resolve` function's result is passed directly to `async_connect`, the
range overload will be selected.]
]
[
[[link boost_asio.reference.basic_socket_streambuf.duration
`basic_socket_streambuf::duration`]]
[[link boost_asio.reference.basic_socket_streambuf.duration_type
`basic_socket_streambuf::duration_type`]]
[]
]
[
[[link boost_asio.reference.basic_socket_streambuf.time_point
`basic_socket_streambuf::time_point`]]
[[link boost_asio.reference.basic_socket_streambuf.time_type
`basic_socket_streambuf::time_type`]]
[]
]
[
[[link boost_asio.reference.basic_socket_streambuf.expiry
`basic_socket_streambuf::expiry`]]
[[link boost_asio.reference.basic_socket_streambuf.expires_at
`basic_socket_streambuf::expires_at`] and [link
boost_asio.reference.basic_socket_streambuf.expires_from_now
`basic_socket_streambuf::expires_from_now`] getters]
[]
]
[
[[link boost_asio.reference.basic_socket_streambuf.expires_after
`basic_socket_streambuf::expires_after`]]
[[link boost_asio.reference.basic_socket_streambuf.expires_from_now
`basic_socket_streambuf::expires_from_now`] setter]
[]
]
[
[[link boost_asio.reference.basic_socket_streambuf.error
`basic_socket_streambuf::error`]]
[[link boost_asio.reference.basic_socket_streambuf.puberror
`basic_socket_streambuf::puberror`]]
[]
]
[
[[link boost_asio.reference.basic_socket_iostream.duration
`basic_socket_iostream::duration`]]
[[link boost_asio.reference.basic_socket_iostream.duration_type
`basic_socket_iostream::duration_type`]]
[]
]
[
[[link boost_asio.reference.basic_socket_iostream.time_point
`basic_socket_iostream::time_point`]]
[[link boost_asio.reference.basic_socket_iostream.time_type
`basic_socket_iostream::time_type`]]
[]
]
[
[[link boost_asio.reference.basic_socket_iostream.expiry
`basic_socket_iostream::expiry`]]
[[link boost_asio.reference.basic_socket_iostream.expires_at
`basic_socket_iostream::expires_at`] and [link
boost_asio.reference.basic_socket_iostream.expires_from_now
`basic_socket_iostream::expires_from_now`] getters]
[]
]
[
[[link boost_asio.reference.basic_socket_iostream.expires_after
`basic_socket_iostream::expires_after`]]
[[link boost_asio.reference.basic_socket_iostream.expires_from_now
`basic_socket_iostream::expires_from_now`] setter]
[]
]
[
[[link boost_asio.reference.basic_waitable_timer.cancel
`basic_waitable_timer::cancel`]]
[[link boost_asio.reference.basic_waitable_timer.cancel
`basic_waitable_timer::cancel`] overload that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.basic_waitable_timer.cancel_one
`basic_waitable_timer::cancel_one`]]
[[link boost_asio.reference.basic_waitable_timer.cancel_one
`basic_waitable_timer::cancel_one`] overload that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.basic_waitable_timer.expires_at
`basic_waitable_timer::expires_at`] setter]
[[link boost_asio.reference.basic_waitable_timer.expires_at
`basic_waitable_timer::expires_at`] setter that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.basic_waitable_timer.expiry
`basic_waitable_timer::expiry`]]
[[link boost_asio.reference.basic_waitable_timer.expires_at
`basic_waitable_timer::expires_at`] and [link
boost_asio.reference.basic_waitable_timer.expires_from_now
`basic_waitable_timer::expires_from_now`] getters]
[]
]
[
[[link boost_asio.reference.basic_waitable_timer.expires_after
`basic_waitable_timer::expires_after`]]
[[link boost_asio.reference.basic_waitable_timer.expires_from_now
`basic_waitable_timer::expires_from_now`] setter]
[]
]
[
[[link boost_asio.reference.ip__address.make_address `ip::make_address`]]
[[link boost_asio.reference.ip__address.from_string `ip::address::from_string`]]
[]
]
[
[[link boost_asio.reference.ip__address_v4.make_address_v4 `ip::make_address_v4`]]
[[link boost_asio.reference.ip__address_v4.from_string
`ip::address_v4::from_string`] and [link
boost_asio.reference.ip__address_v6.to_v4 `ip::address_v6::to_v4`]]
[]
]
[
[[link boost_asio.reference.ip__address_v6.make_address_v6 `ip::make_address_v6`]]
[[link boost_asio.reference.ip__address_v6.from_string
`ip::address_v6::from_string`] and [link
boost_asio.reference.ip__address_v6.v4_mapped `ip::address_v6::v4_mapped`]]
[]
]
[
[[link boost_asio.reference.ip__address.to_string `ip::address::to_string`]]
[[link boost_asio.reference.ip__address.to_string `ip::address::to_string`] that
takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.ip__address_v4.to_string `ip::address_v4::to_string`]]
[[link boost_asio.reference.ip__address_v4.to_string `ip::address_v4::to_string`]
that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link boost_asio.reference.ip__address_v6.to_string `ip::address_v6::to_string`]]
[[link boost_asio.reference.ip__address_v6.to_string `ip::address_v6::to_string`]
that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[No replacement]
[[link boost_asio.reference.ip__address_v6.is_v4_compatible
`ip::address_v6::is_v4_compatible`] and [link
boost_asio.reference.ip__address_v6.v4_compatible
`ip::address_v6::v4_compatible`]]
[]
]
[
[[link boost_asio.reference.ip__network_v4 `ip::network_v4`]]
[[link boost_asio.reference.ip__address_v4.broadcast `ip::address_v4::broadcast`],
[link boost_asio.reference.ip__address_v4.is_class_a `ip::address_v4::is_class_a`],
[link boost_asio.reference.ip__address_v4.is_class_b `ip::address_v4::is_class_b`],
[link boost_asio.reference.ip__address_v4.is_class_c `ip::address_v4::is_class_c`],
and [link boost_asio.reference.ip__address_v4.netmask `ip::address_v4::netmask`]]
[The `network_v4` class adds the ability to manipulate IPv4 network
addresses using CIDR notation.]
]
[
[[link boost_asio.reference.ip__network_v6 `ip::network_v6`]]
[]
[The `network_v6` class adds the ability to manipulate IPv6 network
addresses using CIDR notation.]
]
[
[[link boost_asio.reference.ip__basic_address_iterator_lt__address_v4__gt_
`ip::address_v4_iterator`] and [link
boost_asio.reference.ip__basic_address_range_lt__address_v4__gt_
`ip::address_v4_range`]]
[]
[The `ip::address_v4_iterator` and `address_v4_range` classes add the
ability to iterate over all, or a subset of, IPv4 addresses.]
]
[
[[link boost_asio.reference.ip__basic_address_iterator_lt__address_v6__gt_
`ip::address_v6_iterator`] and [link
boost_asio.reference.ip__basic_address_range_lt__address_v6__gt_
`ip::address_v6_range`]]
[]
[The `ip::address_v6_iterator` and `address_v6_range` classes add the
ability to iterate over all, or a subset of, IPv6 addresses.]
]
[
[[link boost_asio.reference.ip__basic_resolver.results_type
`ip::basic_resolver::results_type`]]
[[link boost_asio.reference.ip__basic_resolver.iterator
`ip::basic_resolver::iterator`]]
[Resolvers now produce ranges rather than single iterators.]
]
[
[[link boost_asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] overloads taking hostname and service as
arguments]
[[link boost_asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] overloads taking a [link
boost_asio.reference.ip__basic_resolver.query `ip::basic_resolver::query`]]
[]
]
[
[[link boost_asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] returns a range]
[[link boost_asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] returns a single iterator]
[]
]
[
[[link boost_asio.reference.ip__basic_resolver.async_resolve
`ip::basic_resolver::async_resolve`] overloads taking hostname and service
as arguments]
[[link boost_asio.reference.ip__basic_resolver.async_resolve
`ip::basic_resolver::async_resolve`] overloads taking a [link
boost_asio.reference.ip__basic_resolver.query `ip::basic_resolver::query`]]
[]
]
[
[[link boost_asio.reference.ip__basic_resolver.async_resolve
`ip::basic_resolver::async_resolve`] calls the handler with a range]
[[link boost_asio.reference.ip__basic_resolver.async_resolve
`ip::basic_resolver::async_resolve`] calls the handler with a single
iterator]
[]
]
]
[endsect]

View File

@@ -0,0 +1,10 @@
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
//
/**
\class noncopyable
*/

View File

@@ -0,0 +1,137 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:overview Overview]
* [link boost_asio.overview.rationale Rationale]
* [link boost_asio.overview.basics Basic Boost.Asio Anatomy]
* [link boost_asio.overview.model Asynchronous Model]
* [link boost_asio.overview.model.async_ops Asynchronous Operations]
* [link boost_asio.overview.model.async_agents Asynchronous Agents]
* [link boost_asio.overview.model.associators Associated Characteristics and Associators]
* [link boost_asio.overview.model.child_agents Child Agents]
* [link boost_asio.overview.model.executors Executors]
* [link boost_asio.overview.model.allocators Allocators]
* [link boost_asio.overview.model.cancellation Cancellation]
* [link boost_asio.overview.model.completion_tokens Completion Tokens]
* [link boost_asio.overview.model.library_elements Supporting Library Elements]
* [link boost_asio.overview.model.higher_levels Higher Level Abstractions]
* [link boost_asio.overview.core Core Concepts and Functionality]
* [link boost_asio.overview.core.async The Proactor Design Pattern: Concurrency Without Threads]
* [link boost_asio.overview.core.threads Threads and Boost.Asio]
* [link boost_asio.overview.core.strands Strands: Use Threads Without Explicit Locking]
* [link boost_asio.overview.core.buffers Buffers]
* [link boost_asio.overview.core.streams Streams, Short Reads and Short Writes]
* [link boost_asio.overview.core.reactor Reactor-Style Operations]
* [link boost_asio.overview.core.line_based Line-Based Operations]
* [link boost_asio.overview.core.allocation Custom Memory Allocation]
* [link boost_asio.overview.core.cancellation Per-Operation Cancellation]
* [link boost_asio.overview.core.handler_tracking Handler Tracking]
* [link boost_asio.overview.core.concurrency_hint Concurrency Hints]
* [link boost_asio.overview.composition Composition and Completion Tokens]
* [link boost_asio.overview.composition.coroutine Stackless Coroutines]
* [link boost_asio.overview.composition.spawn Stackful Coroutines]
* [link boost_asio.overview.composition.cpp20_coroutines C++20 Coroutines Support]
* [link boost_asio.overview.composition.coro Resumable C++20 Coroutines (experimental)]
* [link boost_asio.overview.networking Networking]
* [link boost_asio.overview.networking.protocols TCP, UDP and ICMP]
* [link boost_asio.overview.networking.other_protocols Support for Other Protocols]
* [link boost_asio.overview.networking.iostreams Socket Iostreams]
* [link boost_asio.overview.networking.bsd_sockets The BSD Socket API and Boost.Asio]
* [link boost_asio.overview.timers Timers]
* [link boost_asio.overview.serial_ports Serial Ports]
* [link boost_asio.overview.signals Signal Handling]
* [link boost_asio.overview.posix POSIX-Specific Functionality]
* [link boost_asio.overview.posix.local UNIX Domain Sockets]
* [link boost_asio.overview.posix.stream_descriptor Stream-Oriented File Descriptors]
* [link boost_asio.overview.posix.fork Fork]
* [link boost_asio.overview.windows Windows-Specific Functionality]
* [link boost_asio.overview.windows.stream_handle Stream-Oriented HANDLEs]
* [link boost_asio.overview.windows.random_access_handle Random-Access HANDLEs]
* [link boost_asio.overview.windows.object_handle Object HANDLEs]
* [link boost_asio.overview.ssl SSL]
* [link boost_asio.overview.cpp2011 C++ 2011 Support]
* [link boost_asio.overview.cpp2011.move_objects Movable I/O Objects]
* [link boost_asio.overview.cpp2011.move_handlers Movable Handlers]
* [link boost_asio.overview.cpp2011.variadic Variadic Templates]
* [link boost_asio.overview.cpp2011.array Array Container]
* [link boost_asio.overview.cpp2011.atomic Atomics]
* [link boost_asio.overview.cpp2011.shared_ptr Shared Pointers]
* [link boost_asio.overview.cpp2011.chrono Chrono]
* [link boost_asio.overview.cpp2011.futures Futures]
* [link boost_asio.overview.implementation Platform-Specific Implementation Notes]
[include overview/rationale.qbk]
[include overview/basics.qbk]
[include overview/model.qbk]
[section:core Core Concepts and Functionality]
* [link boost_asio.overview.core.async The Proactor Design Pattern: Concurrency Without Threads]
* [link boost_asio.overview.core.threads Threads and Boost.Asio]
* [link boost_asio.overview.core.strands Strands: Use Threads Without Explicit Locking]
* [link boost_asio.overview.core.buffers Buffers]
* [link boost_asio.overview.core.streams Streams, Short Reads and Short Writes]
* [link boost_asio.overview.core.reactor Reactor-Style Operations]
* [link boost_asio.overview.core.line_based Line-Based Operations]
* [link boost_asio.overview.core.allocation Custom Memory Allocation]
* [link boost_asio.overview.core.cancellation Per-Operation Cancellation]
* [link boost_asio.overview.core.handler_tracking Handler Tracking]
* [link boost_asio.overview.core.concurrency_hint Concurrency Hints]
[include overview/async.qbk]
[include overview/threads.qbk]
[include overview/strands.qbk]
[include overview/buffers.qbk]
[include overview/streams.qbk]
[include overview/reactor.qbk]
[include overview/line_based.qbk]
[include overview/allocation.qbk]
[include overview/cancellation.qbk]
[include overview/handler_tracking.qbk]
[include overview/concurrency_hint.qbk]
[endsect]
[section:composition Composition and Completion Tokens]
* [link boost_asio.overview.composition.coroutine Stackless Coroutines]
* [link boost_asio.overview.composition.spawn Stackful Coroutines]
* [link boost_asio.overview.composition.cpp20_coroutines C++20 Coroutines Support]
* [link boost_asio.overview.composition.coro Resumable C++20 Coroutines (experimental)]
[include overview/coroutine.qbk]
[include overview/spawn.qbk]
[include overview/cpp20_coroutines.qbk]
[include overview/coro.qbk]
[endsect]
[section:networking Networking]
* [link boost_asio.overview.networking.protocols TCP, UDP and ICMP]
* [link boost_asio.overview.networking.other_protocols Support for Other Protocols]
* [link boost_asio.overview.networking.iostreams Socket Iostreams]
* [link boost_asio.overview.networking.bsd_sockets The BSD Socket API and Boost.Asio]
[include overview/protocols.qbk]
[include overview/other_protocols.qbk]
[include overview/iostreams.qbk]
[include overview/bsd_sockets.qbk]
[endsect]
[include overview/timers.qbk]
[include overview/serial_ports.qbk]
[include overview/signals.qbk]
[include overview/posix.qbk]
[include overview/windows.qbk]
[include overview/ssl.qbk]
[include overview/cpp2011.qbk]
[include overview/implementation.qbk]
[endsect]

View File

@@ -0,0 +1,95 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:allocation Custom Memory Allocation]
Many asynchronous operations need to allocate an object to store state
associated with the operation. For example, a Win32 implementation needs
`OVERLAPPED`-derived objects to pass to Win32 API functions.
Furthermore, programs typically contain easily identifiable chains of
asynchronous operations. A half duplex protocol implementation (e.g. an HTTP
server) would have a single chain of operations per client (receives followed
by sends). A full duplex protocol implementation would have two chains
executing in parallel. Programs should be able to leverage this knowledge to
reuse memory for all asynchronous operations in a chain.
Given a copy of a user-defined `Handler` object `h`, if the implementation
needs to allocate memory associated with that handler it will obtain an
allocator using the `get_associated_allocator` function. For example:
boost::asio::associated_allocator_t<Handler> a = boost::asio::get_associated_allocator(h);
The associated allocator must satisfy the standard Allocator requirements.
By default, handlers use the standard allocator (which is implemented in terms
of `::operator new()` and `::operator delete()`). The allocator may be
customised for a particular handler type by specifying a nested type
`allocator_type` and member function `get_allocator()`:
class my_handler
{
public:
// Custom implementation of Allocator type requirements.
typedef my_allocator allocator_type;
// Return a custom allocator implementation.
allocator_type get_allocator() const noexcept
{
return my_allocator();
}
void operator()() { ... }
};
In more complex cases, the `associated_allocator` template may be partially
specialised directly:
namespace boost { namespace asio {
template <typename Allocator>
struct associated_allocator<my_handler, Allocator>
{
// Custom implementation of Allocator type requirements.
typedef my_allocator type;
// Return a custom allocator implementation.
static type get(const my_handler&,
const Allocator& a = Allocator()) noexcept
{
return my_allocator();
}
};
} } // namespace boost::asio
The implementation guarantees that the deallocation will occur before the
associated handler is invoked, which means the memory is ready to be reused for
any new asynchronous operations started by the handler.
The custom memory allocation functions may be called from any user-created
thread that is calling an Boost.Asio library function. The implementation guarantees,
for the asynchronous operations included with the library, that within the
context of an individual operation the implementation will not make concurrent
calls to the memory allocation functions for that handler. The implementation
will insert appropriate memory barriers to ensure correct memory visibility
should an asynchronous operation need to call the allocation functions from
different threads. (Note: If the same allocator is shared across multiple
concurrent asynchronous operations, this can result in concurrent calls to the
memory allocation functions. Use of a [link boost_asio.overview.core.strands strand]
does not prevent these concurrent calls, as an operation may need to allocate
memory from outside the strand. In this case, the shared allocator is
responsible for providing the necessary thread safety guarantees.)
[heading See Also]
[link boost_asio.reference.associated_allocator associated_allocator],
[link boost_asio.reference.get_associated_allocator get_associated_allocator],
[link boost_asio.examples.cpp03_examples.allocation custom memory allocation example (C++03)],
[link boost_asio.examples.cpp11_examples.allocation custom memory allocation example (C++11)].
[endsect]

View File

@@ -0,0 +1,185 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:async The Proactor Design Pattern: Concurrency Without Threads]
The Boost.Asio library offers side-by-side support for synchronous and asynchronous
operations. The asynchronous support is based on the Proactor design pattern
[link boost_asio.overview.core.async.references \[POSA2\]]. The advantages and
disadvantages of this approach, when compared to a synchronous-only or Reactor
approach, are outlined below.
[heading Proactor and Boost.Asio]
Let us examine how the Proactor design pattern is implemented in Boost.Asio,
without reference to platform-specific details.
[$boost_asio/proactor.png]
[*Proactor design pattern (adapted from \[POSA2\])]
[mdash] Asynchronous Operation
[:Defines an operation that is executed asynchronously, such as an asynchronous
read or write on a socket.]
[mdash] Asynchronous Operation Processor
[:Executes asynchronous operations and queues events on a completion event
queue when operations complete. From a high-level point of view, internal
services like `reactive_socket_service` are asynchronous operation processors.]
[mdash] Completion Event Queue
[:Buffers completion events until they are dequeued by an asynchronous event
demultiplexer.]
[mdash] Completion Handler
[:Processes the result of an asynchronous operation. These are function
objects, often created using `boost::bind`.]
[mdash] Asynchronous Event Demultiplexer
[:Blocks waiting for events to occur on the completion event queue, and returns
a completed event to its caller.]
[mdash] Proactor
[:Calls the asynchronous event demultiplexer to dequeue events, and dispatches
the completion handler (i.e. invokes the function object) associated with the
event. This abstraction is represented by the `io_context` class.]
[mdash] Initiator
[:Application-specific code that starts asynchronous operations. The initiator
interacts with an asynchronous operation processor via a high-level interface
such as `basic_stream_socket`, which in turn delegates to a service like
`reactive_socket_service`.]
[heading Implementation Using Reactor]
On many platforms, Boost.Asio implements the Proactor design pattern in terms
of a Reactor, such as `select`, `epoll` or `kqueue`. This implementation
approach corresponds to the Proactor design pattern as follows:
[mdash] Asynchronous Operation Processor
[:A reactor implemented using `select`, `epoll` or `kqueue`. When the reactor
indicates that the resource is ready to perform the operation, the processor
executes the asynchronous operation and enqueues the associated completion
handler on the completion event queue.]
[mdash] Completion Event Queue
[:A linked list of completion handlers (i.e. function objects).]
[mdash] Asynchronous Event Demultiplexer
[:This is implemented by waiting on an event or condition variable until a
completion handler is available in the completion event queue.]
[heading Implementation Using Windows Overlapped I/O]
On Windows NT, 2000 and XP, Boost.Asio takes advantage of overlapped I/O to
provide an efficient implementation of the Proactor design pattern. This
implementation approach corresponds to the Proactor design pattern as follows:
[mdash] Asynchronous Operation Processor
[:This is implemented by the operating system. Operations are initiated by
calling an overlapped function such as `AcceptEx`.]
[mdash] Completion Event Queue
[:This is implemented by the operating system, and is associated with an I/O
completion port. There is one I/O completion port for each `io_context`
instance.]
[mdash] Asynchronous Event Demultiplexer
[:Called by Boost.Asio to dequeue events and their associated completion
handlers.]
[heading Advantages]
[mdash] Portability.
[:Many operating systems offer a native asynchronous I/O API (such as
overlapped I/O on __Windows__) as the preferred option for developing high
performance network applications. The library may be implemented in terms of
native asynchronous I/O. However, if native support is not available, the
library may also be implemented using synchronous event demultiplexors that
typify the Reactor pattern, such as __POSIX__ `select()`.]
[mdash] Decoupling threading from concurrency.
[:Long-duration operations are performed asynchronously by the implementation
on behalf of the application. Consequently applications do not need to spawn
many threads in order to increase concurrency.]
[mdash] Performance and scalability.
[:Implementation strategies such as thread-per-connection (which a
synchronous-only approach would require) can degrade system performance, due to
increased context switching, synchronisation and data movement among CPUs. With
asynchronous operations it is possible to avoid the cost of context switching
by minimising the number of operating system threads [mdash] typically a
limited resource [mdash] and only activating the logical threads of control
that have events to process.]
[mdash] Simplified application synchronisation.
[:Asynchronous operation completion handlers can be written as though they
exist in a single-threaded environment, and so application logic can be
developed with little or no concern for synchronisation issues.]
[mdash] Function composition.
[:Function composition refers to the implementation of functions to provide a
higher-level operation, such as sending a message in a particular format. Each
function is implemented in terms of multiple calls to lower-level read or write
operations.]
[:For example, consider a protocol where each message consists of a
fixed-length header followed by a variable length body, where the length of the
body is specified in the header. A hypothetical read_message operation could be
implemented using two lower-level reads, the first to receive the header and,
once the length is known, the second to receive the body.]
[:To compose functions in an asynchronous model, asynchronous operations can be
chained together. That is, a completion handler for one operation can initiate
the next. Starting the first call in the chain can be encapsulated so that the
caller need not be aware that the higher-level operation is implemented as a
chain of asynchronous operations.]
[:The ability to compose new operations in this way simplifies the development
of higher levels of abstraction above a networking library, such as functions
to support a specific protocol.]
[heading Disadvantages]
[mdash] Program complexity.
[:It is more difficult to develop applications using asynchronous mechanisms
due to the separation in time and space between operation initiation and
completion. Applications may also be harder to debug due to the inverted flow
of control.]
[mdash] Memory usage.
[:Buffer space must be committed for the duration of a read or write operation,
which may continue indefinitely, and a separate buffer is required for each
concurrent operation. The Reactor pattern, on the other hand, does not require
buffer space until a socket is ready for reading or writing.]
[heading References]
\[POSA2\] D. Schmidt et al, ['Pattern Oriented Software Architecture, Volume
2]. Wiley, 2000.
[endsect]

View File

@@ -0,0 +1,78 @@
digraph g
{
graph
[
nodesep="0.2"
];
edge
[
fontname="Helvetica",
fontsize=10,
labelfontname="Helvetica",
labelfontsize=10
];
node
[
fontname="Helvetica",
fontsize=10,
shape=box
];
edge
[
arrowhead="open"
]
// Program elements.
{
operating_system [ label="Operating System", shape=ellipse ];
io_context [ label="I/O Execution Context\ne.g. io_context" ];
io_object [ label="I/O Object\ne.g. socket" ];
your_program [ label="Your Program" ];
your_completion_handler [ label="Your Completion Handler" ];
}
// Owning relationships.
{
edge [ arrowtail="diamond" ];
your_program:e -> your_completion_handler:n;
your_program:w -> io_object:nw;
your_program:se -> io_context:ne;
}
// Non-owning relationships;
{
io_object:sw -> io_context:w;
}
// Visible actions.
{
edge [ style="dashed", color="#808080" ];
// Forward actions.
{
your_program:sw -> io_object:n [ label="1" ];
io_object:s -> io_context:nw [ label="2" ];
io_context:s -> operating_system:n [ label="3" ];
}
}
// Invisible actions.
{
edge [ style="invis" ];
// Forward actions.
{
your_program:s -> io_context:n [ label="5" ];
}
// Reverse actions.
{
edge [ arrowhead="none", arrowtail="open" ];
//io_context:s -> operating_system:n [ label="4" ];
your_completion_handler:s -> io_context:e [ label="6" ];
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1,78 @@
digraph g
{
graph
[
nodesep="0.2"
];
edge
[
fontname="Helvetica",
fontsize=10,
labelfontname="Helvetica",
labelfontsize=10
];
node
[
fontname="Helvetica",
fontsize=10,
shape=box
];
edge
[
arrowhead="open"
]
// Program elements.
{
operating_system [ label="Operating System", shape=ellipse ];
io_context [ label="I/O Execution Context\ne.g. io_context" ];
io_object [ label="I/O Object\ne.g. socket" ];
your_program [ label="Your Program" ];
your_completion_handler [ label="Your Completion Handler" ];
}
// Owning relationships.
{
edge [ arrowtail="diamond" ];
your_program:e -> your_completion_handler:n;
your_program:w -> io_object:nw;
your_program:se -> io_context:ne;
}
// Non-owning relationships;
{
io_object:sw -> io_context:w;
}
// Visible actions.
{
edge [ style="dashed", color="#808080" ];
// Forward actions.
{
your_program:s -> io_context:n [ label="5" ];
}
// Reverse actions.
{
edge [ arrowhead="none", arrowtail="open" ];
io_context:s -> operating_system:n [ label="4" ];
your_completion_handler:s -> io_context:e [ label="6" ];
}
}
// Invisible actions.
{
edge [ style="invis" ];
// Forward actions.
{
your_program:sw -> io_object:n [ label="1" ];
io_object:s -> io_context:nw [ label="2" ];
//io_context:s -> operating_system:n [ label="3" ];
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1,111 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:basics Basic Boost.Asio Anatomy]
Boost.Asio may be used to perform both synchronous and asynchronous operations on I/O
objects such as sockets. Before using Boost.Asio it may be useful to get a conceptual
picture of the various parts of Boost.Asio, your program, and how they work together.
As an introductory example, let's consider what happens when you perform a
connect operation on a socket. We shall start by examining synchronous
operations.
[$boost_asio/sync_op.png]
[*Your program] will have at least one [*I/O execution context], such as an
`boost::asio::io_context` object, `boost::asio::thread_pool` object, or
`boost::asio::system_context`. This [*I/O execution context] represents [*your
program]'s link to the [*operating system]'s I/O services.
boost::asio::io_context io_context;
To perform I/O operations [*your program] will need an [*I/O object] such as a
TCP socket:
boost::asio::ip::tcp::socket socket(io_context);
When a synchronous connect operation is performed, the following sequence of
events occurs:
1. [*Your program] initiates the connect operation by calling the [*I/O
object]:
socket.connect(server_endpoint);
2. The [*I/O object] forwards the request to the [*I/O execution context].
3. The [*I/O execution context] calls on the [*operating system] to perform the
connect operation.
4. The [*operating system] returns the result of the operation to the
[*I/O execution context].
5. The [*I/O execution context] translates any error resulting from the
operation into an object of type `boost::system::error_code`. An `error_code` may be
compared with specific values, or tested as a boolean (where a `false` result
means that no error occurred). The result is then forwarded back up to the
[*I/O object].
6. The [*I/O object] throws an exception of type `boost::system::system_error` if the
operation failed. If the code to initiate the operation had instead been
written as:
boost::system::error_code ec;
socket.connect(server_endpoint, ec);
then the `error_code` variable `ec` would be set to the result of the
operation, and no exception would be thrown.
When an asynchronous operation is used, a different sequence of events occurs.
[$boost_asio/async_op1.png]
1. [*Your program] initiates the connect operation by calling the [*I/O
object]:
socket.async_connect(server_endpoint, your_completion_handler);
where `your_completion_handler` is a function or function object with the
signature:
void your_completion_handler(const boost::system::error_code& ec);
The exact signature required depends on the asynchronous operation being
performed. The reference documentation indicates the appropriate form for each
operation.
2. The [*I/O object] forwards the request to the [*I/O execution context].
3. The [*I/O execution context] signals to the [*operating system] that it
should start an asynchronous connect.
Time passes. (In the synchronous case this wait would have been contained
entirely within the duration of the connect operation.)
[$boost_asio/async_op2.png]
4. The [*operating system] indicates that the connect operation has completed
by placing the result on a queue, ready to be picked up by the [*I/O execution
context].
5. When using an `io_context` as the [*I/O execution context], [*your program]
must make a call to `io_context::run()` (or to one of the similar `io_context`
member functions) in order for the result to be retrieved. A call to
`io_context::run()` blocks while there are unfinished asynchronous operations,
so you would typically call it as soon as you have started your first
asynchronous operation.
6. While inside the call to `io_context::run()`, the [*I/O execution context]
dequeues the result of the operation, translates it into an `error_code`, and
then passes it to [*your completion handler].
This is a simplified picture of how Boost.Asio operates. You will want to delve
further into the documentation if your needs are more advanced, such as
extending Boost.Asio to perform other types of asynchronous operations.
[endsect]

View File

@@ -0,0 +1,270 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:bsd_sockets The BSD Socket API and Boost.Asio]
The Boost.Asio library includes a low-level socket interface based on the BSD socket
API, which is widely implemented and supported by extensive literature. It is
also used as the basis for networking APIs in other languages, like Java. This
low-level interface is designed to support the development of efficient and
scalable applications. For example, it permits programmers to exert finer
control over the number of system calls, avoid redundant data copying, minimise
the use of resources like threads, and so on.
Unsafe and error prone aspects of the BSD socket API are not included. For
example, the use of `int` to represent all sockets lacks type safety. The
socket representation in Boost.Asio uses a distinct type for each protocol, e.g. for
TCP one would use `ip::tcp::socket`, and for UDP one uses `ip::udp::socket`.
The following table shows the mapping between the BSD socket API and Boost.Asio:
[table
[
[BSD Socket API Elements]
[Equivalents in Boost.Asio]
]
[
[socket descriptor - `int` (POSIX) or `SOCKET` (Windows)]
[ For TCP: [link boost_asio.reference.ip__tcp.socket ip::tcp::socket],
[link boost_asio.reference.ip__tcp.acceptor ip::tcp::acceptor]
For UDP: [link boost_asio.reference.ip__udp.socket ip::udp::socket]
[link boost_asio.reference.basic_socket basic_socket],
[link boost_asio.reference.basic_stream_socket basic_stream_socket],
[link boost_asio.reference.basic_datagram_socket basic_datagram_socket],
[link boost_asio.reference.basic_raw_socket basic_raw_socket] ]
]
[
[`in_addr`,
`in6_addr`]
[ [link boost_asio.reference.ip__address ip::address],
[link boost_asio.reference.ip__address ip::address_v4],
[link boost_asio.reference.ip__address ip::address_v6] ]
]
[
[`sockaddr_in`,
`sockaddr_in6`]
[ For TCP: [link boost_asio.reference.ip__tcp.endpoint ip::tcp::endpoint]
For UDP: [link boost_asio.reference.ip__udp.endpoint ip::udp::endpoint]
[link boost_asio.reference.ip__basic_endpoint ip::basic_endpoint] ]
]
[
[`accept()`]
[ For TCP: [link boost_asio.reference.basic_socket_acceptor.accept ip::tcp::acceptor::accept()]
[link boost_asio.reference.basic_socket_acceptor.accept basic_socket_acceptor::accept()] ]
]
[
[`bind()`]
[ For TCP: [link boost_asio.reference.basic_socket.bind ip::tcp::acceptor::bind()],
[link boost_asio.reference.basic_socket.bind ip::tcp::socket::bind()]
For UDP: [link boost_asio.reference.basic_socket.bind ip::udp::socket::bind()]
[link boost_asio.reference.basic_socket.bind basic_socket::bind()] ]
]
[
[`close()`]
[ For TCP: [link boost_asio.reference.basic_socket.close ip::tcp::acceptor::close()],
[link boost_asio.reference.basic_socket.close ip::tcp::socket::close()]
For UDP: [link boost_asio.reference.basic_socket.close ip::udp::socket::close()]
[link boost_asio.reference.basic_socket.close basic_socket::close()] ]
]
[
[`connect()`]
[ For TCP: [link boost_asio.reference.basic_socket.connect ip::tcp::socket::connect()]
For UDP: [link boost_asio.reference.basic_socket.connect ip::udp::socket::connect()]
[link boost_asio.reference.basic_socket.connect basic_socket::connect()] ]
]
[
[`getaddrinfo()`,
`gethostbyaddr()`,
`gethostbyname()`,
`getnameinfo()`,
`getservbyname()`,
`getservbyport()`]
[ For TCP: [link boost_asio.reference.ip__basic_resolver.resolve ip::tcp::resolver::resolve()],
[link boost_asio.reference.ip__basic_resolver.async_resolve ip::tcp::resolver::async_resolve()]
For UDP: [link boost_asio.reference.ip__basic_resolver.resolve ip::udp::resolver::resolve()],
[link boost_asio.reference.ip__basic_resolver.async_resolve ip::udp::resolver::async_resolve()]
[link boost_asio.reference.ip__basic_resolver.resolve ip::basic_resolver::resolve()],
[link boost_asio.reference.ip__basic_resolver.async_resolve ip::basic_resolver::async_resolve()] ]
]
[
[`gethostname()`]
[ [link boost_asio.reference.ip__host_name ip::host_name()] ]
]
[
[`getpeername()`]
[ For TCP: [link boost_asio.reference.basic_socket.remote_endpoint ip::tcp::socket::remote_endpoint()]
For UDP: [link boost_asio.reference.basic_socket.remote_endpoint ip::udp::socket::remote_endpoint()]
[link boost_asio.reference.basic_socket.remote_endpoint basic_socket::remote_endpoint()] ]
]
[
[`getsockname()`]
[ For TCP: [link boost_asio.reference.basic_socket.local_endpoint ip::tcp::acceptor::local_endpoint()],
[link boost_asio.reference.basic_socket.local_endpoint ip::tcp::socket::local_endpoint()]
For UDP: [link boost_asio.reference.basic_socket.local_endpoint ip::udp::socket::local_endpoint()]
[link boost_asio.reference.basic_socket.local_endpoint basic_socket::local_endpoint()] ]
]
[
[`getsockopt()`]
[ For TCP: [link boost_asio.reference.basic_socket.get_option ip::tcp::acceptor::get_option()],
[link boost_asio.reference.basic_socket.get_option ip::tcp::socket::get_option()]
For UDP: [link boost_asio.reference.basic_socket.get_option ip::udp::socket::get_option()]
[link boost_asio.reference.basic_socket.get_option basic_socket::get_option()] ]
]
[
[`inet_addr()`,
`inet_aton()`,
`inet_pton()`]
[ [link boost_asio.reference.ip__address.from_string ip::address::from_string()],
[link boost_asio.reference.ip__address.from_string ip::address_v4::from_string()],
[link boost_asio.reference.ip__address.from_string ip_address_v6::from_string()] ]
]
[
[`inet_ntoa()`,
`inet_ntop()`]
[ [link boost_asio.reference.ip__address.to_string ip::address::to_string()],
[link boost_asio.reference.ip__address.to_string ip::address_v4::to_string()],
[link boost_asio.reference.ip__address.to_string ip_address_v6::to_string()] ]
]
[
[`ioctl()`]
[ For TCP: [link boost_asio.reference.basic_socket.io_control ip::tcp::socket::io_control()]
For UDP: [link boost_asio.reference.basic_socket.io_control ip::udp::socket::io_control()]
[link boost_asio.reference.basic_socket.io_control basic_socket::io_control()] ]
]
[
[`listen()`]
[ For TCP: [link boost_asio.reference.basic_socket_acceptor.listen ip::tcp::acceptor::listen()]
[link boost_asio.reference.basic_socket_acceptor.listen basic_socket_acceptor::listen()] ]
]
[
[`poll()`,
`select()`,
`pselect()`]
[ [link boost_asio.reference.io_context.run io_context::run()],
[link boost_asio.reference.io_context.run_one io_context::run_one()],
[link boost_asio.reference.io_context.poll io_context::poll()],
[link boost_asio.reference.io_context.poll_one io_context::poll_one()]
Note: in conjunction with asynchronous operations. ]
]
[
[`readv()`,
`recv()`,
`read()`]
[ For TCP: [link boost_asio.reference.basic_stream_socket.read_some ip::tcp::socket::read_some()],
[link boost_asio.reference.basic_stream_socket.async_read_some ip::tcp::socket::async_read_some()],
[link boost_asio.reference.basic_stream_socket.receive ip::tcp::socket::receive()],
[link boost_asio.reference.basic_stream_socket.async_receive ip::tcp::socket::async_receive()]
For UDP: [link boost_asio.reference.basic_datagram_socket.receive ip::udp::socket::receive()],
[link boost_asio.reference.basic_datagram_socket.async_receive ip::udp::socket::async_receive()]
[link boost_asio.reference.basic_stream_socket.read_some basic_stream_socket::read_some()],
[link boost_asio.reference.basic_stream_socket.async_read_some basic_stream_socket::async_read_some()],
[link boost_asio.reference.basic_stream_socket.receive basic_stream_socket::receive()],
[link boost_asio.reference.basic_stream_socket.async_receive basic_stream_socket::async_receive()],
[link boost_asio.reference.basic_datagram_socket.receive basic_datagram_socket::receive()],
[link boost_asio.reference.basic_datagram_socket.async_receive basic_datagram_socket::async_receive()] ]
]
[
[`recvfrom()`]
[ For UDP: [link boost_asio.reference.basic_datagram_socket.receive_from ip::udp::socket::receive_from()],
[link boost_asio.reference.basic_datagram_socket.async_receive_from ip::udp::socket::async_receive_from()]
[link boost_asio.reference.basic_datagram_socket.receive_from basic_datagram_socket::receive_from()],
[link boost_asio.reference.basic_datagram_socket.async_receive_from basic_datagram_socket::async_receive_from()] ]
]
[
[`send()`,
`write()`,
`writev()`]
[ For TCP: [link boost_asio.reference.basic_stream_socket.write_some ip::tcp::socket::write_some()],
[link boost_asio.reference.basic_stream_socket.async_write_some ip::tcp::socket::async_write_some()],
[link boost_asio.reference.basic_stream_socket.send ip::tcp::socket::send()],
[link boost_asio.reference.basic_stream_socket.async_send ip::tcp::socket::async_send()]
For UDP: [link boost_asio.reference.basic_datagram_socket.send ip::udp::socket::send()],
[link boost_asio.reference.basic_datagram_socket.async_send ip::udp::socket::async_send()]
[link boost_asio.reference.basic_stream_socket.write_some basic_stream_socket::write_some()],
[link boost_asio.reference.basic_stream_socket.async_write_some basic_stream_socket::async_write_some()],
[link boost_asio.reference.basic_stream_socket.send basic_stream_socket::send()],
[link boost_asio.reference.basic_stream_socket.async_send basic_stream_socket::async_send()],
[link boost_asio.reference.basic_datagram_socket.send basic_datagram_socket::send()],
[link boost_asio.reference.basic_datagram_socket.async_send basic_datagram_socket::async_send()] ]
]
[
[`sendto()`]
[ For UDP: [link boost_asio.reference.basic_datagram_socket.send_to ip::udp::socket::send_to()],
[link boost_asio.reference.basic_datagram_socket.async_send_to ip::udp::socket::async_send_to()]
[link boost_asio.reference.basic_datagram_socket.send_to basic_datagram_socket::send_to()],
[link boost_asio.reference.basic_datagram_socket.async_send_to basic_datagram_socket::async_send_to()] ]
]
[
[`setsockopt()`]
[ For TCP: [link boost_asio.reference.basic_socket.set_option ip::tcp::acceptor::set_option()],
[link boost_asio.reference.basic_socket.set_option ip::tcp::socket::set_option()]
For UDP: [link boost_asio.reference.basic_socket.set_option ip::udp::socket::set_option()]
[link boost_asio.reference.basic_socket.set_option basic_socket::set_option()] ]
]
[
[`shutdown()`]
[ For TCP: [link boost_asio.reference.basic_socket.shutdown ip::tcp::socket::shutdown()]
For UDP: [link boost_asio.reference.basic_socket.shutdown ip::udp::socket::shutdown()]
[link boost_asio.reference.basic_socket.shutdown basic_socket::shutdown()] ]
]
[
[`sockatmark()`]
[ For TCP: [link boost_asio.reference.basic_socket.at_mark ip::tcp::socket::at_mark()]
[link boost_asio.reference.basic_socket.at_mark basic_socket::at_mark()] ]
]
[
[`socket()`]
[ For TCP: [link boost_asio.reference.basic_socket.open ip::tcp::acceptor::open()],
[link boost_asio.reference.basic_socket.open ip::tcp::socket::open()]
For UDP: [link boost_asio.reference.basic_socket.open ip::udp::socket::open()]
[link boost_asio.reference.basic_socket.open basic_socket::open()] ]
]
[
[`socketpair()`]
[ [link boost_asio.reference.local__connect_pair local::connect_pair()]
Note: POSIX operating systems only. ]
]
]
[endsect]

View File

@@ -0,0 +1,163 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:buffers Buffers]
Fundamentally, I/O involves the transfer of data to and from contiguous regions
of memory, called buffers. These buffers can be simply expressed as a tuple
consisting of a pointer and a size in bytes. However, to allow the development
of efficient network applications, Boost.Asio includes support for scatter-gather
operations. These operations involve one or more buffers:
* A scatter-read receives data into multiple buffers.
* A gather-write transmits multiple buffers.
Therefore we require an abstraction to represent a collection of buffers. The
approach used in Boost.Asio is to define a type (actually two types) to
represent a single buffer. These can be stored in a container, which may be
passed to the scatter-gather operations.
In addition to specifying buffers as a pointer and size in bytes, Boost.Asio makes a
distinction between modifiable memory (called mutable) and non-modifiable
memory (where the latter is created from the storage for a const-qualified
variable). These two types could therefore be defined as follows:
typedef std::pair<void*, std::size_t> mutable_buffer;
typedef std::pair<const void*, std::size_t> const_buffer;
Here, a mutable_buffer would be convertible to a const_buffer, but conversion
in the opposite direction is not valid.
However, Boost.Asio does not use the above definitions as-is, but instead defines two
classes: `mutable_buffer` and `const_buffer`. The goal of these is to provide
an opaque representation of contiguous memory, where:
* Types behave as std::pair would in conversions. That is, a `mutable_buffer` is
convertible to a `const_buffer`, but the opposite conversion is disallowed.
* There is protection against buffer overruns. Given a buffer instance, a user
can only create another buffer representing the same range of memory or a
sub-range of it. To provide further safety, the library also includes
mechanisms for automatically determining the size of a buffer from an array,
`boost::array` or `std::vector` of POD elements, or from a `std::string`.
* The underlying memory is explicitly accessed using the `data()` member
function. In general an application should never need to do this, but it is
required by the library implementation to pass the raw memory to the
underlying operating system functions.
Finally, multiple buffers can be passed to scatter-gather operations (such as
[link boost_asio.reference.read read()] or [link boost_asio.reference.write write()]) by
putting the buffer objects into a container. The `MutableBufferSequence` and
`ConstBufferSequence` concepts have been defined so that containers such as
`std::vector`, `std::list`, `std::array` or `boost::array` can be used.
[heading Streambuf for Integration with Iostreams]
The class `boost::asio::basic_streambuf` is derived from `std::basic_streambuf` to
associate the input sequence and output sequence with one or more objects of
some character array type, whose elements store arbitrary values. These
character array objects are internal to the streambuf object, but direct access
to the array elements is provided to permit them to be used with I/O
operations, such as the send or receive operations of a socket:
* The input sequence of the streambuf is accessible via the [link
boost_asio.reference.basic_streambuf.data data()] member function. The return type
of this function meets the `ConstBufferSequence` requirements.
* The output sequence of the streambuf is accessible via the [link
boost_asio.reference.basic_streambuf.prepare prepare()] member function. The return
type of this function meets the `MutableBufferSequence` requirements.
* Data is transferred from the front of the output sequence to the back of the
input sequence by calling the [link boost_asio.reference.basic_streambuf.commit
commit()] member function.
* Data is removed from the front of the input sequence by calling the [link
boost_asio.reference.basic_streambuf.consume consume()] member function.
The streambuf constructor accepts a `size_t` argument specifying the maximum of
the sum of the sizes of the input sequence and output sequence. Any operation
that would, if successful, grow the internal data beyond this limit will throw
a `std::length_error` exception.
[heading Bytewise Traversal of Buffer Sequences]
The `buffers_iterator<>` class template allows buffer sequences (i.e. types
meeting `MutableBufferSequence` or `ConstBufferSequence` requirements) to be
traversed as though they were a contiguous sequence of bytes. Helper functions
called buffers_begin() and buffers_end() are also provided, where the
buffers_iterator<> template parameter is automatically deduced.
As an example, to read a single line from a socket and into a `std::string`,
you may write:
boost::asio::streambuf sb;
...
std::size_t n = boost::asio::read_until(sock, sb, '\n');
boost::asio::streambuf::const_buffers_type bufs = sb.data();
std::string line(
boost::asio::buffers_begin(bufs),
boost::asio::buffers_begin(bufs) + n);
[heading Buffer Debugging]
Some standard library implementations, such as the one that ships with
Microsoft Visual C++ 8.0 and later, provide a feature called iterator
debugging. What this means is that the validity of iterators is checked at
runtime. If a program tries to use an iterator that has been invalidated, an
assertion will be triggered. For example:
std::vector<int> v(1)
std::vector<int>::iterator i = v.begin();
v.clear(); // invalidates iterators
*i = 0; // assertion!
Boost.Asio takes advantage of this feature to add buffer debugging. Consider the
following code:
void dont_do_this()
{
std::string msg = "Hello, world!";
boost::asio::async_write(sock, boost::asio::buffer(msg), my_handler);
}
When you call an asynchronous read or write you need to ensure that the buffers
for the operation are valid until the completion handler is called. In the
above example, the buffer is the `std::string` variable `msg`. This variable is
on the stack, and so it goes out of scope before the asynchronous operation
completes. If you're lucky then the application will crash, but random failures
are more likely.
When buffer debugging is enabled, Boost.Asio stores an iterator into the string until
the asynchronous operation completes, and then dereferences it to check its
validity. In the above example you would observe an assertion failure just
before Boost.Asio tries to call the completion handler.
This feature is automatically made available for Microsoft Visual Studio 8.0 or
later and for GCC when `_GLIBCXX_DEBUG` is defined. There is a performance cost
to this checking, so buffer debugging is only enabled in debug builds. For
other compilers it may be enabled by defining `BOOST_ASIO_ENABLE_BUFFER_DEBUGGING`.
It can also be explicitly disabled by defining `BOOST_ASIO_DISABLE_BUFFER_DEBUGGING`.
[heading See Also]
[link boost_asio.reference.buffer buffer],
[link boost_asio.reference.buffers_begin buffers_begin],
[link boost_asio.reference.buffers_end buffers_end],
[link boost_asio.reference.buffers_iterator buffers_iterator],
[link boost_asio.reference.const_buffer const_buffer],
[link boost_asio.reference.const_buffers_1 const_buffers_1],
[link boost_asio.reference.mutable_buffer mutable_buffer],
[link boost_asio.reference.mutable_buffers_1 mutable_buffers_1],
[link boost_asio.reference.streambuf streambuf],
[link boost_asio.reference.ConstBufferSequence ConstBufferSequence],
[link boost_asio.reference.MutableBufferSequence MutableBufferSequence],
[link boost_asio.examples.cpp03_examples.buffers buffers example (C++03)],
[link boost_asio.examples.cpp11_examples.buffers buffers example (c++11)].
[endsect]

View File

@@ -0,0 +1,255 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:cancellation Per-Operation Cancellation]
[note These type requirements and classes are the low level building blocks of
cancellation. For most use cases, consider using a higher level abstraction,
such as [link boost_asio.reference.experimental__make_parallel_group
experimental::make_parallel_group] or the [link
boost_asio.overview.composition.cpp20_coroutines.co_ordinating_parallel_coroutines
logical operators] for `awaitable`.]
I/O objects, such as sockets and timers, support object-wide cancellation of
outstanding asynchronous operations via their `close` or `cancel` member
functions. However, certain asynchronous operations also support individual,
targeted cancellation. This per-operation cancellation is enabled by
specifying that a completion handler has an [link
boost_asio.reference.associated_cancellation_slot associated cancellation slot]
which satisfies the [link boost_asio.reference.CancellationSlot CancellationSlot]
type requirements. A cancellation slot is a lightweight channel used for
delivering a cancellation request.
Given a copy of a user-defined `Handler` object `h`, if an asynchronous
operation supports cancellation it will obtain a cancellation slot using the
`get_associated_cancellation_slot` function. For example:
boost::asio::associated_cancellation_slot_t<Handler> s
= boost::asio::get_associated_cancellation_slot(h);
The associated cancellation slot must satisfy the CancellationSlot type
requirements.
By default, handlers use a default-constructed [link
boost_asio.reference.cancellation_slot `cancellation_slot`], which means that
per-operation cancellation is disabled. The cancellation slot may be customised
for a particular handler type by specifying a nested type
`cancellation_slot_type` and member function `get_cancellation_slot()`:
class my_handler
{
public:
// Custom implementation of CancellationSlot type requirements.
typedef my_cancellation_slot cancellation_slot_type;
// Return a custom cancellation slot implementation.
cancellation_slot_type get_cancellation_slot() const noexcept
{
return my_cancellation_slot(...);
}
void operator()() { ... }
};
In more complex cases, the `associated_cancellation_slot` template may be
partially specialised directly:
namespace boost { namespace asio {
template <typename CancellationSlot>
struct associated_cancellation_slot<my_handler, CancellationSlot>
{
// Custom implementation of CancellationSlot type requirements.
typedef my_cancellation_slot type;
// Return a custom cancellation_slot implementation.
static type get(const my_handler&,
const CancellationSlot& a = CancellationSlot()) noexcept
{
return my_cancellation_slot(...);
}
};
} } // namespace boost::asio
For convenience, a cancellation slot may be associated with a handler by using
the [link boost_asio.reference.bind_cancellation_slot `bind_cancellation_slot`]
function. This is particularly useful when associating a cancellation slot with
a lambda:
boost::asio::async_read(my_socket, my_buffer,
boost::asio::bind_cancellation_slot(
my_cancellation_slot,
[](boost::system::error_code e, std::size_t n)
{
...
}
)
);
Boost.Asio provides a ready-to-use cancellation slot in the form of [link
boost_asio.reference.cancellation_slot `cancellation_slot`] and its counterpart [link
boost_asio.reference.cancellation_signal `cancellation_signal`]. These two classes
implement a one-to-one pairing of producer (signal) and consumer (slot)
interfaces. The following example shows its use:
class session
: public std::enable_shared_from_this<proxy>
{
...
void do_read()
{
auto self = shared_from_this();
socket_.async_read_some(
buffer(data_),
boost::asio::bind_cancellation_slot(
cancel_signal_.slot(),
[self](boost::system::error_code error, std::size_t n)
{
...
}
)
);
}
...
void request_cancel()
{
cancel_signal_.emit(boost::asio::cancellation_type::total);
}
...
boost::asio::cancellation_signal cancel_signal_;
};
A `cancellation_signal` contains a single slot, and consequently a cancellation
signal/slot pair may be used with at most one operation at a time. However,
the same slot may be reused for subsequent operations.
To support cancellation, an asynchronous operation installs a cancellation
handler into the slot by calling the slot's `assign` or `emplace` functions.
This handler will be invoked when a cancellation signal is emitted. A slot
holds exactly one handler at a time, and installing a new handler will overwrite
any previously installed handler.
When emitting a cancellation signal, the caller must specify a [link
boost_asio.reference.cancellation_type cancellation type]. This value is a bitmask
that dictates what guarantees the cancellation target must make if
successful cancellation occurs. The possible bit values are, from weakest
to strongest guarantee, are:
[table cancellation types
[
[Bit]
[Guarantee if cancellation is successful]
[Examples where this is the strongest supported guarantee]
]
[
[`terminal`]
[
The operation had unspecified side effects, and it is only safe to close
or destroy the I/O object.
]
[
A stateful implementation of a message framing protocol, where an
asynchronous operation sends or receives a complete message. If
cancellation occurs part-way through the message body, it is not possible
to report a sensible state to the completion handler.
]
]
[
[`partial`]
[
The operation had well-defined side effects, and the completion
handler for the operation indicates what these side effects were.
]
[
Composed operations such as `async_read` and `async_write`. If cancellation
occurs before all bytes are transferred, the completion handler is passed
the total bytes transferred so far. The caller may use this information
to start another operation to transfer the remaining bytes.
]
]
[
[`total`]
[
The operation had no side effects that are observable through the API.
]
[
Low level system calls that transfer either zero or non-zero bytes.[br]
[br]
Wait-for-readiness operations that have no side effects, even when
successful.[br]
[br]
A fully buffered message framing protocol implementation, where partial
messages are stored so that they may be reused on the next operation.
]
]
]
For example, if application logic requires that an operation complete with
all-or-nothing side effects, it should emit only the `total` cancellation type.
If this type is unsupported by the target operation, no cancellation will
occur.
Furthermore, a stronger guarantee always satisfies the requirements of a weaker
guarantee. The `partial` guarantee still satisfies the `terminal` guarantee.
The `total` guarantee satisfies both `partial` and `total`. This means that
when an operation supports a given cancellation type as its strongest
guarantee, it should honour cancellation requests for any of the weaker
guarantees.
Cancellation requests should not be emitted during an asynchronous operation's
initiating function. Cancellation requests that are emitted before an operation
starts have no effect. Similarly, cancellation requests made after completion
have no effect.
When emitting a cancellation signal, the thread safety rules apply as if
calling a member function on the target operation's I/O object. For
non-composed operations, this means that it is safe to emit the cancellation
signal from any thread provided there are no other concurrent calls to the I/O
object, and no other concurrent cancellation signal requests. For composed
operations, care must be taken to ensure the cancellation request does not
occur concurrently with the operation's intermediate completion handlers.
[heading Supported Operations]
Consult the documentation for individual asynchronous operations for their
supported cancellation types, if any. The ability to cancel individual
operations, or composed operations, is currently supported by:
* timers
* sockets on POSIX and Windows
* POSIX descriptors
* Windows HANDLEs
* signal sets
* serial ports
* SSL streams
* all Boost.Asio-provided composed operations such as `async_read` and `async_write`
* compositions based on `async_compose`
* C++20 coroutines that use `awaitable`
* C++20 coroutines that use `experimental::coro`
* the `experimental::parallel_group` operation
* the `experimental::promise` class
[heading See Also]
[link boost_asio.reference.CancellationSlot CancellationSlot],
[link boost_asio.reference.associated_cancellation_slot associated_cancellation_slot],
[link boost_asio.reference.bind_cancellation_slot bind_cancellation_slot],
[link boost_asio.reference.cancellation_signal cancellation_signal],
[link boost_asio.reference.cancellation_slot cancellation_slot],
[link boost_asio.reference.cancellation_state cancellation_state],
[link boost_asio.reference.cancellation_type cancellation_type],
[link boost_asio.reference.get_associated_cancellation_slot get_associated_cancellation_slot],
[link boost_asio.reference.experimental__parallel_group experimental::parallel_group],
[link boost_asio.reference.experimental__make_parallel_group experimental::make_parallel_group]
[endsect]

View File

@@ -0,0 +1,93 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:concurrency_hint Concurrency Hints]
The [link boost_asio.reference.io_context.io_context `io_context` constructor]
allows programs to specify a concurrency hint. This is a suggestion to the
`io_context` implementation as to the number of active threads that should be
used for running completion handlers.
When the Windows I/O completion port backend is in use, this value is passed
to [^CreateIoCompletionPort].
When a reactor-based backend is used, the implementation recognises the
following special concurrency hint values:
[table
[[Value][Description]]
[
[`1`]
[
The implementation assumes that the `io_context` will be run from a
single thread, and applies several optimisations based on this
assumption.
For example, when a handler is posted from within another handler, the
new handler is added to a fast thread-local queue (with the consequence
that the new handler is held back until the currently executing handler
finishes).
The `io_context` still provides full thread safety, and distinct I/O
objects may be used from any thread.
]
]
[
[`BOOST_ASIO_CONCURRENCY_HINT_UNSAFE`]
[
This special concurrency hint disables locking in both the scheduler and
reactor I/O. This hint has the following restrictions:
[mdash] Care must be taken to ensure that all operations on the
`io_context` and any of its associated I/O objects (such as sockets and
timers) occur in only one thread at a time.
[mdash] Asynchronous resolve operations fail with `operation_not_supported`.
[mdash] If a `signal_set` is used with the `io_context`, `signal_set`
objects cannot be used with any other io_context in the program.
]
]
[
[`BOOST_ASIO_CONCURRENCY_HINT_UNSAFE_IO`]
[
This special concurrency hint disables locking in the reactor I/O. This
hint has the following restrictions:
[mdash] Care must be taken to ensure that the ['run functions] on the
`io_context` (i.e. `run`, `run_for`, `run_until`, `run_one`,
`run_one_for`, `run_one_until`, `poll`, and `poll_one`), and all
operations on the context's associated I/O objects (such as sockets and
timers), occur in only one thread at a time.
]
]
[
[`BOOST_ASIO_CONCURRENCY_HINT_SAFE`]
[
The default. The `io_context` provides full thread safety, and distinct
I/O objects may be used from any thread.
]
]
]
[teletype]
The concurrency hint used by default-constructed `io_context` objects can be
overridden at compile time by defining the `BOOST_ASIO_CONCURRENCY_HINT_DEFAULT`
macro. For example, specifying
-DBOOST_ASIO_CONCURRENCY_HINT_DEFAULT=1
on the compiler command line means that a concurrency hint of `1` is used for
all default-constructed `io_context` objects in the program. Similarly, the
concurrency hint used by `io_context` objects constructed with `1` can be
overridden by defining `BOOST_ASIO_CONCURRENCY_HINT_1`. For example, passing
-DBOOST_ASIO_CONCURRENCY_HINT_1=BOOST_ASIO_CONCURRENCY_HINT_UNSAFE
to the compiler will disable thread safety for all of these objects.
[endsect]

View File

@@ -0,0 +1,260 @@
[/
/ Copyright (c) 2021-2022 Klemens D. Morgenstern
/ (klemens dot morgenstern at gmx dot net)
/
/ 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)
/]
[section:coro Resumable C++ 20 Coroutines]
[note This is an experimental feature.]
The [link boost_asio.reference.experimental__coro `experimental::coro`] class provides
support for a universal C++20 coroutine. These coroutines can be used as tasks,
generators and transfomers, depending on their signature.
coro<std::string_view> line_reader(tcp::socket stream)
{
while (stream.is_open())
{
std::array<char, 4096> buf;
auto read = co_await stream.async_read_some(
boost::asio::buffer(buf), experimental::use_coro);
if (read == 0u)
continue;
co_yield std::string_view { buf.data(), read };
}
}
coro<void, std::size_t> line_logger(tcp::socket stream)
{
std::size_t lines_read = 0u;
auto reader = line_reader(std::move(stream));
while (auto l = co_await reader)
{
std::cout << "Read: '" << *l << "'" << std::endl;
lines_read++;
}
co_return lines_read;
}
void read_lines(tcp::socket sock)
{
co_spawn(line_logger(std::move(sock),
[](std::exception_ptr, std::size_t lines)
{
std::clog << "Read " << lines << " lines" << std::endl;
}));
}
A [link boost_asio.reference.experimental__coro `coro`] is highly configurable, so
that it can cover a set of different use cases.
template<
typename Yield,
typename Return = void,
typename Executor = any_io_executor>
struct coro;
[heading Yield]
The `Yield` parameter designates how a `co_yield` statement behaves. It can
either be a type, like `int` or a signature with zero or one types:
coro<void> // A coroutine with no yield
coro<int> // A coroutine that can yield int
coro<void()> // A coroutine with no yield
coro<int()> // A coroutine that can yield int
coro<int(double)> // A coroutine that can yield int and receive double
Receiving a value means that the `co_yield` statement returns a value.
coro<int(int)> my_sum(any_io_executor)
{
int value = 0;
while (true)
value += co_yield value; //sum up all values
}
Putting values into a coroutine can be done it two ways: either by direct
resumption (from another coro) or through async_resume. The first value gets
ignored because the coroutines are lazy.
coro<void> c(any_io_executor exec)
{
auto sum = my_sum(exec);
assert(0 == co_await sum(-1));
assert(0 == co_await sum(10));
assert(10 == co_await sum(15));
assert(25 == co_await sum(0));
}
awaitable<void> a()
{
auto sum = my_sum(co_await this_coro::executor);
assert(0 == co_await sum.async_resume(-1, use_awaitable));
assert(0 == co_await sum.async_resume(10, use_awaitable));
assert(10 == co_await sum.async_resume(15, use_awaitable));
assert(25 == co_await sum.async_resume(0, use_awaitable));
}
[heading `noexcept`]
A coro may be noexcept:
coro<void() noexcept> c;
coro<int() noexcept> c;
coro<int(double) noexcept> c;
This will change its @c async_resume signature, from `void(std::exception_ptr)`
to `void()` or `void(std::exception_ptr, T)` to `void(T)`. A noexcept coro that
ends with an exception will cause `std::terminate` to be called.
Furthermore, calls of `async_resume` and `co_await` of an expired noexcept coro
will cause undefined behaviour.
[heading Return]
A coro can also define a type that can be used with `co_return`:
coro<void() noexcept, int> c(any_io_executor)
{
co_return 42;
}
A coro can have both a `Yield` and `Return` that are non void at the same time.
[heading Result]
The result type of a coroutine is dermined by both `Yield` and `Return`. Note
that in the follwing table only the yield output value is considered, i.e.
`T(U)` means `T`.
[table:result_type Result type deduction
[[Yield] [Return] [`noexcept`] [`result_type`] [`completion_signature`]]
[[`T`] [`U`] [`false`] [`variant<T, U>`] [`void(std::exception_ptr, variant<T, U>)`]]
[[`T`] [`U`] [`true`] [`variant<T, U>`] [`void(variant<T, U>)`]]
[[`T`] [`void`] [`false`] [`optional<T>`] [`void(std::exception_ptr, optional<T>)`]]
[[`T`] [`void`] [`true`] [`optional<T>`] [`void(optional<T>)`]]
[[`void`] [`void`] [`false`] [`optional<T>`] [`void(std::exception_ptr)`]]
[[`void`] [`void`] [`true`] [`optional<T>`] [`void()`]]
[[`void`] [`T`] [`false`] [`optional<T>`] [`void(std::exception_ptr, T)`]]
[[`void`] [`T`] [`true`] [`optional<T>`] [`void(T)`]]
]
[heading Executor]
Every coroutine needs to have its own executor. Since the coroutine gets called
multiple times, it cannot take the executor from the caller like an
`awaitable`. Therefore a `coro` requires to get an executor or an
execution_context passed in as the first parameter.
coro<int> with_executor(any_io_executor);
coro<int> with_context(io_context &);
It is to note, that an execution_context is defined as loosely as possible. An
execution context is any object that has a `get_executor()` function, which
returns an executor that can be transformed into the executor_type of the
coroutine. This allows most io_objects to be used as the source of the
executor:
coro<int> with_socket(tcp::socket);
Additionally, a `coro` that is a member function will check the `this` pointer
as well, either if it's an executor or an execution context:
struct my_io_object
{
any_io_executor get_executor();
coro<int> my_coro();
};
Finally, a member coro can be given an explicit executor or execution
context, to override the one of the object:
struct my_io_object
{
any_io_executor get_executor();
coro<int> my_coro(any_io_executor exec); // it will use exec
};
[heading `co_await`]
The @c co_await within a `coro` is not the same as `async_resume(use_coro)`,
unless both coros use different executors. If they use the same, the `coro`
will direclty suspend and resume the executor, without any usage of the
executor.
`co_await this_coro::` behaves the same as coroutines that use
@c boost::asio::awaitable.
[heading Integrating with awaitable]
As the `coro` member function `async_resume` is an asynchronous operation, it
may also be used in conjunction with `awaitable` coroutines in a single control
flow. For example:
#include <asio.hpp>
#include <boost/asio/experimental/coro.hpp>
using boost::asio::ip::tcp;
boost::asio::experimental::coro<std::string> reader(tcp::socket& sock)
{
std::string buf;
while (sock.is_open())
{
std::size_t n = co_await boost::asio::async_read_until(
sock, boost::asio::dynamic_buffer(buf), '\n',
boost::asio::experimental::use_coro);
co_yield buf.substr(0, n);
buf.erase(0, n);
}
}
boost::asio::awaitable<void> consumer(tcp::socket sock)
{
auto r = reader(sock);
auto msg1 = co_await r.async_resume(boost::asio::use_awaitable);
std::cout << "Message 1: " << msg1.value_or("\n");
auto msg2 = co_await r.async_resume(boost::asio::use_awaitable);
std::cout << "Message 2: " << msg2.value_or("\n");
}
boost::asio::awaitable<void> listen(tcp::acceptor& acceptor)
{
for (;;)
{
co_spawn(
acceptor.get_executor(),
consumer(co_await acceptor.async_accept(boost::asio::use_awaitable)),
boost::asio::detached);
}
}
int main()
{
boost::asio::io_context ctx;
tcp::acceptor acceptor(ctx, {tcp::v4(), 54321});
co_spawn(ctx, listen(acceptor), boost::asio::detached);
ctx.run();
}
[heading See Also]
[link boost_asio.reference.co_spawn co_spawn],
[link boost_asio.reference.experimental__coro experimental::coro],
[link boost_asio.overview.composition.cpp20_coroutines C++20 Coroutines],
[link boost_asio.overview.composition.spawn Stackful Coroutines],
[link boost_asio.overview.composition.coroutine Stackless Coroutines].
[endsect]

View File

@@ -0,0 +1,51 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:coroutine Stackless Coroutines]
The [link boost_asio.reference.coroutine `coroutine`] class provides support for
stackless coroutines. Stackless coroutines enable programs to implement
asynchronous logic in a synchronous manner, with minimal overhead, as shown in
the following example:
struct session : boost::asio::coroutine
{
boost::shared_ptr<tcp::socket> socket_;
boost::shared_ptr<std::vector<char> > buffer_;
session(boost::shared_ptr<tcp::socket> socket)
: socket_(socket),
buffer_(new std::vector<char>(1024))
{
}
void operator()(boost::system::error_code ec = boost::system::error_code(), std::size_t n = 0)
{
if (!ec) reenter (this)
{
for (;;)
{
yield socket_->async_read_some(boost::asio::buffer(*buffer_), *this);
yield boost::asio::async_write(*socket_, boost::asio::buffer(*buffer_, n), *this);
}
}
}
};
The `coroutine` class is used in conjunction with the pseudo-keywords
`reenter`, `yield` and `fork`. These are preprocessor macros, and are
implemented in terms of a `switch` statement using a technique similar to
Duff's Device. The [link boost_asio.reference.coroutine `coroutine`] class's
documentation provides a complete description of these pseudo-keywords.
[heading See Also]
[link boost_asio.reference.coroutine coroutine],
[link boost_asio.examples.cpp03_examples.http_server_4 HTTP Server 4 example],
[link boost_asio.overview.composition.spawn Stackful Coroutines].
[endsect]

View File

@@ -0,0 +1,250 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:cpp2011 C++ 2011 Support]
[link boost_asio.overview.cpp2011.move_objects Movable I/O Objects]
[link boost_asio.overview.cpp2011.move_handlers Movable Handlers]
[link boost_asio.overview.cpp2011.variadic Variadic Templates]
[link boost_asio.overview.cpp2011.array Array Container]
[link boost_asio.overview.cpp2011.atomic Atomics]
[link boost_asio.overview.cpp2011.shared_ptr Shared Pointers]
[link boost_asio.overview.cpp2011.chrono Chrono]
[link boost_asio.overview.cpp2011.futures Futures]
[section:move_objects Movable I/O Objects]
When move support is available (via rvalue references), Boost.Asio allows move
construction and assignment of sockets, serial ports, POSIX descriptors and
Windows handles.
Move support allows you to write code like:
tcp::socket make_socket(io_context& i)
{
tcp::socket s(i);
...
std::move(s);
}
or:
class connection : public enable_shared_from_this<connection>
{
private:
tcp::socket socket_;
...
public:
connection(tcp::socket&& s) : socket_(std::move(s)) {}
...
};
...
class server
{
private:
tcp::acceptor acceptor_;
...
void handle_accept(error_code ec, tcp::socket socket)
{
if (!ec)
std::make_shared<connection>(std::move(socket))->go();
acceptor_.async_accept(...);
}
...
};
as well as:
std::vector<tcp::socket> sockets;
sockets.push_back(tcp::socket(...));
A word of warning: There is nothing stopping you from moving these objects
while there are pending asynchronous operations, but it is unlikely to be a
good idea to do so. In particular, composed operations like [link
boost_asio.reference.async_read async_read()] store a reference to the stream object.
Moving during the composed operation means that the composed operation may
attempt to access a moved-from object.
Move support is automatically enabled for [^g++] 4.5 and later, when the
[^-std=c++0x] or [^-std=gnu++0x] compiler options are used. It may be disabled
by defining `BOOST_ASIO_DISABLE_MOVE`, or explicitly enabled for other compilers by
defining `BOOST_ASIO_HAS_MOVE`. Note that these macros also affect the availability
of [link boost_asio.overview.cpp2011.move_handlers movable handlers].
[endsect]
[section:move_handlers Movable Handlers]
With C++11 and later, user-defined completion handlers are only required to be
move constructible, and are not required to be copy constructible.
When move support is enabled, asynchronous that are documented as follows:
template <typename Handler>
void async_XYZ(..., Handler handler);
are actually declared as:
template <typename Handler>
void async_XYZ(..., Handler&& handler);
The handler argument is perfectly forwarded and the move construction occurs
within the body of `async_XYZ()`. This ensures that all other function
arguments are evaluated prior to the move. This is critical when the other
arguments to `async_XYZ()` are members of the handler. For example:
struct my_operation
{
unique_ptr<tcp::socket> socket;
unique_ptr<vector<char>> buffer;
...
void operator(error_code ec, size_t length)
{
...
socket->async_read_some(boost::asio::buffer(*buffer), std::move(*this));
...
}
};
Move support is automatically enabled for [^g++] 4.5 and later, when the
[^-std=c++0x] or [^-std=gnu++0x] compiler options are used. It may be disabled
by defining `BOOST_ASIO_DISABLE_MOVE`, or explicitly enabled for other compilers by
defining `BOOST_ASIO_HAS_MOVE`. Note that these macros also affect the availability
of [link boost_asio.overview.cpp2011.move_objects movable I/O objects].
[endsect]
[section:variadic Variadic Templates]
When supported by a compiler, Boost.Asio can use variadic templates to implement the
[link boost_asio.reference.basic_socket_streambuf.connect
basic_socket_streambuf::connect()] and [link
boost_asio.reference.basic_socket_iostream.connect basic_socket_iostream::connect()]
functions.
Support for variadic templates is automatically enabled for [^g++] 4.3 and
later, when the [^-std=c++0x] or [^-std=gnu++0x] compiler options are used. It
may be disabled by defining `BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES`, or explicitly
enabled for other compilers by defining `BOOST_ASIO_HAS_VARIADIC_TEMPLATES`.
[endsect]
[section:array Array Container]
Where the standard library provides `std::array<>`, Boost.Asio:
* Provides overloads for the [link boost_asio.reference.buffer buffer()] function.
* Uses it in preference to `boost::array<>` for the
[link boost_asio.reference.ip__address_v4.bytes_type ip::address_v4::bytes_type] and
[link boost_asio.reference.ip__address_v6.bytes_type ip::address_v6::bytes_type]
types.
* Uses it in preference to `boost::array<>` where a fixed size array type is
needed in the implementation.
Support for `std::array<>` is automatically enabled for [^g++] 4.3 and later,
when the [^-std=c++0x] or [^-std=gnu++0x] compiler options are used, as well as
for Microsoft Visual C++ 10. It may be disabled by defining
`BOOST_ASIO_DISABLE_STD_ARRAY`, or explicitly enabled for other compilers by
defining `BOOST_ASIO_HAS_STD_ARRAY`.
[endsect]
[section:atomic Atomics]
Boost.Asio's implementation can use `std::atomic<>` in preference to
`boost::detail::atomic_count`.
Support for the standard atomic integer template is automatically enabled for
[^g++] 4.5 and later, when the [^-std=c++0x] or [^-std=gnu++0x] compiler
options are used. It may be disabled by defining `BOOST_ASIO_DISABLE_STD_ATOMIC`, or
explicitly enabled for other compilers by defining `BOOST_ASIO_HAS_STD_ATOMIC`.
[endsect]
[section:shared_ptr Shared Pointers]
Boost.Asio's implementation can use `std::shared_ptr<>` and `std::weak_ptr<>` in
preference to the Boost equivalents.
Support for the standard smart pointers is automatically enabled for [^g++] 4.3
and later, when the [^-std=c++0x] or [^-std=gnu++0x] compiler options are used,
as well as for Microsoft Visual C++ 10. It may be disabled by defining
`BOOST_ASIO_DISABLE_STD_SHARED_PTR`, or explicitly enabled for other compilers by
defining `BOOST_ASIO_HAS_STD_SHARED_PTR`.
[endsect]
[section:chrono Chrono]
Boost.Asio provides timers based on the `std::chrono` facilities via the [link
boost_asio.reference.basic_waitable_timer basic_waitable_timer] class template.
The typedefs [link boost_asio.reference.system_timer system_timer], [link
boost_asio.reference.steady_timer steady_timer] and [link
boost_asio.reference.high_resolution_timer high_resolution_timer] utilise the
standard clocks `system_clock`, `steady_clock` and `high_resolution_clock`
respectively.
Support for the `std::chrono` facilities is automatically enabled for [^g++]
4.6 and later, when the [^-std=c++0x] or [^-std=gnu++0x] compiler options are
used. (Note that, for [^g++], the draft-standard `monotonic_clock` is used in
place of `steady_clock`.) Support may be disabled by defining
`BOOST_ASIO_DISABLE_STD_CHRONO`, or explicitly enabled for other compilers by
defining `BOOST_ASIO_HAS_STD_CHRONO`.
When standard `chrono` is unavailable, Boost.Asio will otherwise use the Boost.Chrono
library. The [link boost_asio.reference.basic_waitable_timer basic_waitable_timer]
class template may be used with either.
[endsect]
[section:futures Futures]
The `boost::asio::use_future` special value provides first-class support for returning a
C++11 `std::future` from an asynchronous operation's initiating function.
To use `boost::asio::use_future`, pass it to an asynchronous operation instead of
a normal completion handler. For example:
std::future<std::size_t> length =
my_socket.async_read_some(my_buffer, boost::asio::use_future);
Where a handler signature has the form:
void handler(boost::system::error_code ec, result_type result);
the initiating function returns a `std::future` templated on `result_type`.
In the above example, this is `std::size_t`. If the asynchronous operation
fails, the `error_code` is converted into a `system_error` exception and
passed back to the caller through the future.
Where a handler signature has the form:
void handler(boost::system::error_code ec);
the initiating function returns `std::future<void>`. As above, an error
is passed back in the future as a `system_error` exception.
[link boost_asio.reference.use_future use_future],
[link boost_asio.reference.use_future_t use_future_t],
[link boost_asio.examples.cpp11_examples.futures Futures example (C++11)].
[endsect]
[endsect]

View File

@@ -0,0 +1,239 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:cpp20_coroutines C++20 Coroutines Support]
Support for C++20 Coroutines is provided via the [link boost_asio.reference.awaitable
`awaitable`] class template, the [link boost_asio.reference.use_awaitable_t
`use_awaitable`] completion token, and the [link boost_asio.reference.co_spawn
`co_spawn()`] function. These facilities allow programs to implement
asynchronous logic in a synchronous manner, in conjunction with the `co_await`
keyword, as shown in the following example:
boost::asio::co_spawn(executor, echo(std::move(socket)), boost::asio::detached);
// ...
boost::asio::awaitable<void> echo(tcp::socket socket)
{
try
{
char data[1024];
for (;;)
{
std::size_t n = co_await socket.async_read_some(boost::asio::buffer(data), boost::asio::use_awaitable);
co_await async_write(socket, boost::asio::buffer(data, n), boost::asio::use_awaitable);
}
}
catch (std::exception& e)
{
std::printf("echo Exception: %s\n", e.what());
}
}
The first argument to `co_spawn()` is an [link boost_asio.reference.Executor1
executor] that determines the context in which the coroutine is permitted to
execute. For example, a server's per-client object may consist of multiple
coroutines; they should all run on the same `strand` so that no explicit
synchronisation is required.
The second argument is an [link boost_asio.reference.awaitable `awaitable<R>`],
that is the result of the coroutine's entry point function, and in the above
example is the result of the call to `echo`. (Alternatively, this argument can
be a function object that returns the [link boost_asio.reference.awaitable
`awaitable<R>`].) The template parameter `R` is the type of return value
produced by the coroutine. In the above example, the coroutine returns `void`.
The third argument is a completion token, and this is used by `co_spawn()` to
produce a completion handler with signature `void(std::exception_ptr, R)`. This
completion handler is invoked with the result of the coroutine once it has
finished. In the above example we pass a completion token type, [link
boost_asio.reference.detached `boost::asio::detached`], which is used to explicitly ignore
the result of an asynchronous operation.
In this example the body of the coroutine is implemented in the `echo`
function. When the `use_awaitable` completion token is passed to an
asynchronous operation, the operation's initiating function returns an
`awaitable` that may be used with the `co_await` keyword:
std::size_t n = co_await socket.async_read_some(boost::asio::buffer(data), boost::asio::use_awaitable);
Where an asynchronous operation's handler signature has the form:
void handler(boost::system::error_code ec, result_type result);
the resulting type of the `co_await` expression is `result_type`. In the
`async_read_some` example above, this is `size_t`. If the asynchronous
operation fails, the `error_code` is converted into a `system_error` exception
and thrown.
Where a handler signature has the form:
void handler(boost::system::error_code ec);
the `co_await` expression produces a `void` result. As above, an error is
passed back to the coroutine as a `system_error` exception.
[heading Error Handling]
To perform explicit error handling, rather than the default exception-throwing
behaviour, use the [link boost_asio.reference.experimental__as_tuple
`experimental::as_tuple`] or [link boost_asio.reference.redirect_error
`redirect_error`] completion token adapters.
The `experimental::as_tuple` completion token adapter packages the completion
handler arguments into a single tuple, which is then returned as the result of
the awaited operation. For example:
boost::asio::awaitable<void> echo(tcp::socket socket)
{
char data[1024];
for (;;)
{
std::tuple<boost::system::error_code, std::size_t> result =
co_await socket.async_read_some(boost::asio::buffer(data),
boost::asio::experimental::as_tuple(boost::asio::use_awaitable));
if (!std::get<0>(result))
{
// success
}
// ...
}
}
The result can also be captured directly into a structured binding:
boost::asio::awaitable<void> echo(tcp::socket socket)
{
char data[1024];
for (;;)
{
auto [ec, n] = co_await socket.async_read_some(boost::asio::buffer(data),
boost::asio::experimental::as_tuple(boost::asio::use_awaitable));
if (!ec)
{
// success
}
// ...
}
}
Alternatively, the `redirect_error` completion token adapter may be used to
capture the error into a supplied `error_code` variable:
boost::asio::awaitable<void> echo(tcp::socket socket)
{
char data[1024];
for (;;)
{
boost::system::error_code ec;
std::size_t n = co_await socket.async_read_some(boost::asio::buffer(data),
boost::asio::redirect_error(boost::asio::use_awaitable, ec));
if (!ec)
{
// success
}
// ...
}
}
[heading Coroutines and Per-Operation Cancellation]
All threads of execution created by `co_spawn` have a cancellation state that
records the current state of any cancellation requests made to the coroutine.
To access this state, use [link boost_asio.reference.this_coro__cancellation_state
`this_coro::cancellation_state`] as follows:
boost::asio::awaitable<void> my_coroutine()
{
boost::asio::cancellation_state cs
= co_await boost::asio::this_coro::cancellation_state;
// ...
if (cs.cancelled() != boost::asio::cancellation_type::none)
// ...
}
When first created by `co_spawn`, the thread of execution has a cancellation
state that supports `cancellation_type::terminal` values only. To change the
cancellation state, call [link
boost_asio.reference.this_coro__reset_cancellation_state
`this_coro::reset_cancellation_state`].
By default, continued execution of a cancelled coroutine will trigger an
exception from any subsequent `co_await` of an `awaitable<>` object. This
behaviour can be changed by using [link
boost_asio.reference.this_coro__throw_if_cancelled `this_coro::throw_if_cancelled`].
[heading Co-ordinating Parallel Coroutines]
[note This is an experimental feature.]
The logical operators `||` and `&&` have been overloaded for `awaitable<>`, to
allow coroutines to be trivially awaited in parallel.
When awaited using `&&`, the `co_await` expression waits until both operations
have completed successfully. As a "short-circuit" evaluation, if one
operation fails with an exception, the other is immediately cancelled.
For example:
std::tuple<std::size_t, std::size_t> results =
co_await (
async_read(socket, input_buffer, use_awaitable)
&& async_write(socket, output_buffer, use_awaitable)
);
Following completion of a `&&` operation, the results of all operations are
concatenated into a tuple. In the above example, the first `size_t` represents
the non-exceptional component of the `async_read` result, and the second
`size_t` is the result of the `async_write`.
When awaited using `||`, the `co_await` expression waits until either
operation succeeds. As a "short-circuit" evaluation, if one operation
succeeds without throwing an exception, the other is immediately cancelled.
For example:
std::variant<std::size_t, std::monostate> results =
co_await (
async_read(socket, input_buffer, use_awaitable)
|| timer.async_wait(use_awaitable)
);
Following completion of a `||` operation, the result of the first operation to
complete non-exceptionally is placed into a `std::variant`. The active index
of the variant reflects which of the operations completed first.
In the above example, index `0` corresponds to the `async_read` operation.
These operators may be enabled by adding the `#include`:
#include <boost/asio/experimental/awaitable_operators.hpp>
and then bringing the contents of the `experimental::awaitable_operators`
namespace into scope:
using namespace boost::asio::experimental::awaitable_operators;
[heading See Also]
[link boost_asio.reference.co_spawn co_spawn],
[link boost_asio.reference.detached detached],
[link boost_asio.reference.redirect_error redirect_error],
[link boost_asio.reference.awaitable awaitable],
[link boost_asio.reference.use_awaitable_t use_awaitable_t],
[link boost_asio.reference.use_awaitable use_awaitable],
[link boost_asio.reference.this_coro__executor this_coro::executor],
[link boost_asio.reference.experimental__coro experimental::coro],
[link boost_asio.examples.cpp17_examples.coroutines_ts_support Coroutines examples],
[link boost_asio.overview.composition.coro Resumable C++20 Coroutines],
[link boost_asio.overview.composition.spawn Stackful Coroutines],
[link boost_asio.overview.composition.coroutine Stackless Coroutines].
[endsect]

View File

@@ -0,0 +1,281 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:handler_tracking Handler Tracking]
To aid in debugging asynchronous programs, Boost.Asio provides support for handler
tracking. When enabled by defining `BOOST_ASIO_ENABLE_HANDLER_TRACKING`, Boost.Asio
writes debugging output to the standard error stream. The output records
asynchronous operations and the relationships between their handlers.
[teletype]
This feature is useful when debugging and you need to know how your
asynchronous operations are chained together, or what the pending asynchronous
operations are. As an illustration, here is the output when you run the HTTP
Server example, handle a single request, then shut down via Ctrl+C:
@asio|1589424178.741850|0*1|signal_set@0x7ffee977d878.async_wait
@asio|1589424178.742593|0*2|socket@0x7ffee977d8a8.async_accept
@asio|1589424178.742619|.2|non_blocking_accept,ec=asio.system:11
@asio|1589424178.742625|0|resolver@0x7ffee977d760.cancel
@asio|1589424195.830382|.2|non_blocking_accept,ec=system:0
@asio|1589424195.830413|>2|ec=system:0
@asio|1589424195.830473|2*3|socket@0x7fa71d808230.async_receive
@asio|1589424195.830496|.3|non_blocking_recv,ec=system:0,bytes_transferred=151
@asio|1589424195.830503|2*4|socket@0x7ffee977d8a8.async_accept
@asio|1589424195.830507|.4|non_blocking_accept,ec=asio.system:11
@asio|1589424195.830510|<2|
@asio|1589424195.830529|>3|ec=system:0,bytes_transferred=151
@asio|1589424195.831143|3^5|in 'async_write' (./../../../boost/asio/impl/write.hpp:330)
@asio|1589424195.831143|3*5|socket@0x7fa71d808230.async_send
@asio|1589424195.831186|.5|non_blocking_send,ec=system:0,bytes_transferred=1090
@asio|1589424195.831194|<3|
@asio|1589424195.831218|>5|ec=system:0,bytes_transferred=1090
@asio|1589424195.831263|5|socket@0x7fa71d808230.close
@asio|1589424195.831298|<5|
@asio|1589424199.793770|>1|ec=system:0,signal_number=2
@asio|1589424199.793781|1|socket@0x7ffee977d8a8.close
@asio|1589424199.793809|<1|
@asio|1589424199.793840|>4|ec=asio.system:125
@asio|1589424199.793854|<4|
@asio|1589424199.793883|0|signal_set@0x7ffee977d878.cancel
Each line is of the form:
<tag>|<timestamp>|<action>|<description>
The `<tag>` is always `@asio`, and is used to identify and extract the handler
tracking messages from the program output.
The `<timestamp>` is seconds and microseconds from 1 Jan 1970 UTC.
The `<action>` takes one of the following forms:
[variablelist
[
[>n]
[The program entered the handler number `n`. The `<description>` shows the
arguments to the handler.]
]
[
[<n]
[The program left handler number `n`.]
]
[
[!n]
[The program left handler number n due to an exception.]
]
[
[~n]
[The handler number `n` was destroyed without having been invoked. This is
usually the case for any unfinished asynchronous operations when the
`io_context` is destroyed.]
]
[
[n^m]
[The handler number `n` is about to create a new asynchronous operation with
completion handler number `m`. The `<description>` contains source location
information to help identify where in the program the asynchronous operation
is being started.]
]
[
[n*m]
[The handler number `n` created a new asynchronous operation with completion
handler number `m`. The `<description>` shows what asynchronous operation
was started.]
]
[
[n]
[The handler number `n` performed some other operation. The `<description>`
shows what function was called. Currently only `close()` and `cancel()`
operations are logged, as these may affect the state of pending
asynchronous operations.]
]
[
[.n]
[The implementation performed a system call as part of the asynchronous
operation for which handler number `n` is the completion handler. The
`<description>` shows what function was called and its results. These
tracking events are only emitted when using a reactor-based
implementation.]
]
]
Where the `<description>` shows a synchronous or asynchronous operation, the
format is `<object-type>@<pointer>.<operation>`. For handler entry, it shows a
comma-separated list of arguments and their values.
As shown above, Each handler is assigned a numeric identifier. Where the
handler tracking output shows a handler number of 0, it means that the action
was performed outside of any handler.
[heading Adding Location Information]
[c++]
Programs may augment the handler tracking output's location information by
using the macro `BOOST_ASIO_HANDLER_LOCATION` in the source code. For example:
#define HANDLER_LOCATION \
BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, __func__))
// ...
void do_read()
{
HANDLER_LOCATION;
auto self(shared_from_this());
socket_.async_read_some(boost::asio::buffer(data_, max_length),
[this, self](boost::system::error_code ec, std::size_t length)
{
HANDLER_LOCATION;
if (!ec)
{
do_write(length);
}
});
}
[teletype]
With the additional location information available, the handler tracking output
may include a call stack of source locations:
@asio|1589423304.861944|>7|ec=system:0,bytes_transferred=5
@asio|1589423304.861952|7^8|in 'async_write' (./../../../boost/asio/impl/write.hpp:330)
@asio|1589423304.861952|7^8|called from 'do_write' (handler_tracking/async_tcp_echo_server.cpp:62)
@asio|1589423304.861952|7^8|called from 'operator()' (handler_tracking/async_tcp_echo_server.cpp:51)
@asio|1589423304.861952|7*8|socket@0x7ff61c008230.async_send
@asio|1589423304.861975|.8|non_blocking_send,ec=system:0,bytes_transferred=5
@asio|1589423304.861980|<7|
Furthermore, if `std::source_location` or `std::experimental::source_location`
are available, the [link boost_asio.reference.use_awaitable_t `use_awaitable_t`]
token (when default-constructed or used as a default completion token) will
also cause handler tracking to output a source location for each newly created
asynchronous operation. A `use_awaitable_t` object may also be explicitly
constructed with location information.
[heading Visual Representations]
The handler tracking output may be post-processed using the included
[^handlerviz.pl] tool to create a visual representation of the handlers
(requires the GraphViz tool [^dot]).
[c++]
[heading Custom Tracking]
Handling tracking may be customised by defining the
`BOOST_ASIO_CUSTOM_HANDLER_TRACKING` macro to the name of a header file
(enclosed in `""` or `<>`). This header file must implement the following
preprocessor macros:
[table
[[Macro] [Description]]
[
[`BOOST_ASIO_INHERIT_TRACKED_HANDLER`]
[Specifies a base class for classes that implement asynchronous operations.
When used, the macro immediately follows the class name, so it must have
the form `: public my_class`.]
]
[
[`BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER`]
[Specifies a base class for classes that implement asynchronous operations.
When used, the macro follows other base classes, so it must have the form
`, public my_class`.]
]
[
[`BOOST_ASIO_HANDLER_TRACKING_INIT(args)`]
[An expression that is used to initialise the tracking mechanism.]
]
[
[`BOOST_ASIO_HANDLER_LOCATION(args)`]
[A variable declaration that is used to define a source code location.
`args` is a parenthesised function argument list containing the file
name, line number, and function name.]
]
[
[`BOOST_ASIO_HANDLER_CREATION(args)`]
[An expression that is called on creation of an asynchronous operation.
`args` is a parenthesised function argument list containing the owning
execution context, the tracked handler, the name of the object type, a
pointer to the object, the object's native handle, and the operation name.]
]
[
[`BOOST_ASIO_HANDLER_COMPLETION(args)`]
[An expression that is called on completion of an asynchronous operation.
`args` is a parenthesised function argument list containing the tracked
handler.]
]
[
[`BOOST_ASIO_HANDLER_INVOCATION_BEGIN(args)`]
[An expression that is called immediately before a completion handler is
invoked. `args` is a parenthesised function argument list containing the
arguments to the completion handler.]
]
[
[`BOOST_ASIO_HANDLER_INVOCATION_END`]
[An expression that is called immediately after a completion handler is
invoked.]
]
[
[`BOOST_ASIO_HANDLER_OPERATION(args)`]
[An expression that is called when some synchronous object operation is
called (such as `close()` or `cancel()`). `args` is a parenthesised
function argument list containing the owning execution context, the name
of the object type, a pointer to the object, the object's native handle,
and the operation name.]
]
[
[`BOOST_ASIO_HANDLER_REACTOR_REGISTRATION(args)`]
[An expression that is called when an object is registered with the
reactor. `args` is a parenthesised function argument list containing the
owning execution context, the object's native handle, and a unique
registration key.]
]
[
[`BOOST_ASIO_HANDLER_REACTOR_DEREGISTRATION(args)`]
[An expression that is called when an object is deregistered from the
reactor. `args` is a parenthesised function argument list containing the
owning execution context, the object's native handle, and a unique
registration key.]
]
[
[`BOOST_ASIO_HANDLER_REACTOR_READ_EVENT`]
[A bitmask constant used to identify reactor read readiness events.]
]
[
[`BOOST_ASIO_HANDLER_REACTOR_WRITE_EVENT`]
[A bitmask constant used to identify reactor write readiness events.]
]
[
[`BOOST_ASIO_HANDLER_REACTOR_ERROR_EVENT`]
[A bitmask constant used to identify reactor error readiness events.]
]
[
[`BOOST_ASIO_HANDLER_REACTOR_EVENTS(args)`]
[An expression that is called when an object registered with the reactor
becomes ready. `args` is a parenthesised function argument list containing
the owning execution context, the unique registration key, and a bitmask of
the ready events.]
]
[
[`BOOST_ASIO_HANDLER_REACTOR_OPERATION(args)`]
[An expression that is called when the implementation performs a system
call as part of a reactor-based asynchronous operation. `args` is a
parenthesised function argument list containing the tracked handler, the
operation name, the error code produced by the operation, and (optionally)
the number of bytes transferred.]
]
]
[heading See Also]
[link boost_asio.examples.cpp11_examples.handler_tracking Handler tracking
examples].
[endsect]

View File

@@ -0,0 +1,314 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:implementation Platform-Specific Implementation Notes]
This section lists platform-specific implementation details, such as the
default demultiplexing mechanism, the number of threads created internally, and
when threads are created.
[heading Linux Kernel 2.4]
Demultiplexing mechanism:
* Uses `select` for demultiplexing. This means that the number of file
descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:
* Demultiplexing using `select` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading Linux Kernel 2.6]
Demultiplexing mechanism:
* Uses `epoll` for demultiplexing.
Threads:
* Demultiplexing using `epoll` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading Solaris]
Demultiplexing mechanism:
* Uses [^/dev/poll] for demultiplexing.
Threads:
* Demultiplexing using [^/dev/poll] is performed in one of the threads that
calls `io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading QNX Neutrino]
Demultiplexing mechanism:
* Uses `select` for demultiplexing. This means that the number of file
descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:
* Demultiplexing using `select` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading Mac OS X]
Demultiplexing mechanism:
* Uses `kqueue` for demultiplexing.
Threads:
* Demultiplexing using `kqueue` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading FreeBSD]
Demultiplexing mechanism:
* Uses `kqueue` for demultiplexing.
Threads:
* Demultiplexing using `kqueue` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading AIX]
Demultiplexing mechanism:
* Uses `select` for demultiplexing. This means that the number of file
descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:
* Demultiplexing using `select` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading HP-UX]
Demultiplexing mechanism:
* Uses `select` for demultiplexing. This means that the number of file
descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:
* Demultiplexing using `select` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading Tru64]
Demultiplexing mechanism:
* Uses `select` for demultiplexing. This means that the number of file
descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:
* Demultiplexing using `select` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* At most `min(64,IOV_MAX)` buffers may be transferred in a single operation.
[heading Windows 95, 98 and Me]
Demultiplexing mechanism:
* Uses `select` for demultiplexing.
Threads:
* Demultiplexing using `select` is performed in one of the threads that calls
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* For sockets, at most 16 buffers may be transferred in a single operation.
[heading Windows NT, 2000, XP, 2003, Vista, 7 and 8]
Demultiplexing mechanism:
* Uses overlapped I/O and I/O completion ports for all asynchronous socket
operations except for asynchronous connect.
* Uses `select` for emulating asynchronous connect.
Threads:
* Demultiplexing using I/O completion ports is performed in all threads that call
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.
* An additional thread per `io_context` is used to trigger timers. This thread
is created on construction of the first `basic_deadline_timer` or
`basic_waitable_timer` objects.
* An additional thread per `io_context` may be used for `select`
demultiplexing. This thread is created on the first call to:
* A socket `async_wait()` function, except when using `wait_read` on
a stream-oriented socket. (For `wait_read` on a stream-oriented socket,
the overlapped I/O operation `WSARecv` is used and no additional thread
is required.)
* A socket `async_connect()` operation, if the overlapped I/O
operation `ConnectEx` is unavailable. (On recent versions of Windows,
`ConnectEx` is used and no additional thread is required.)
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.
Scatter-Gather:
* For sockets, at most 64 buffers may be transferred in a single operation.
* For stream-oriented handles, only one buffer may be transferred in a single
operation.
[heading Windows Runtime]
Boost.Asio provides limited support for the Windows Runtime. It requires that the
language extensions be enabled. Due to the restricted facilities exposed by the
Windows Runtime API, the support comes with the following caveats:
* The core facilities such as the `io_context`, `strand`, buffers, composed
operations, timers, etc., should all work as normal.
* For sockets, only client-side TCP is supported.
* Explicit binding of a client-side TCP socket is not supported.
* The `cancel()` function is not supported for sockets. Asynchronous
operations may only be cancelled by closing the socket.
* Operations that use `null_buffers` are not supported.
* Only `tcp::no_delay` and `socket_base::keep_alive` options are supported.
* Resolvers do not support service names, only numbers. I.e. you must
use "80" rather than "http".
* Most resolver query flags have no effect.
Demultiplexing mechanism:
* Uses the `Windows::Networking::Sockets::StreamSocket` class to implement
asynchronous TCP socket operations.
Threads:
* Event completions are delivered to the Windows thread pool and posted to the
`io_context` for the handler to be executed.
* An additional thread per `io_context` is used to trigger timers. This thread
is created on construction of the first timer objects.
Scatter-Gather:
* For sockets, at most one buffer may be transferred in a single operation.
[endsect]

View File

@@ -0,0 +1,72 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:iostreams Socket Iostreams]
Boost.Asio includes classes that implement iostreams on top of sockets. These hide
away the complexities associated with endpoint resolution, protocol
independence, etc. To create a connection one might simply write:
ip::tcp::iostream stream("www.boost.org", "http");
if (!stream)
{
// Can't connect.
}
The iostream class can also be used in conjunction with an acceptor to create
simple servers. For example:
io_context ioc;
ip::tcp::endpoint endpoint(tcp::v4(), 80);
ip::tcp::acceptor acceptor(ios, endpoint);
for (;;)
{
ip::tcp::iostream stream;
acceptor.accept(stream.socket());
...
}
Timeouts may be set by calling `expires_at()` or `expires_from_now()` to
establish a deadline. Any socket operations that occur past the deadline will
put the iostream into a "bad" state.
For example, a simple client program like this:
ip::tcp::iostream stream;
stream.expires_from_now(boost::posix_time::seconds(60));
stream.connect("www.boost.org", "http");
stream << "GET /LICENSE_1_0.txt HTTP/1.0\r\n";
stream << "Host: www.boost.org\r\n";
stream << "Accept: */*\r\n";
stream << "Connection: close\r\n\r\n";
stream.flush();
std::cout << stream.rdbuf();
will fail if all the socket operations combined take longer than 60 seconds.
If an error does occur, the iostream's `error()` member function may be used to
retrieve the error code from the most recent system call:
if (!stream)
{
std::cout << "Error: " << stream.error().message() << "\n";
}
[heading See Also]
[link boost_asio.reference.ip__tcp.iostream ip::tcp::iostream],
[link boost_asio.reference.basic_socket_iostream basic_socket_iostream],
[link boost_asio.examples.cpp03_examples.iostreams iostreams examples].
[heading Notes]
These iostream templates only support `char`, not `wchar_t`, and do not perform
any code conversion.
[endsect]

View File

@@ -0,0 +1,118 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:line_based Line-Based Operations]
Many commonly-used internet protocols are line-based, which means that they
have protocol elements that are delimited by the character sequence `"\r\n"`.
Examples include HTTP, SMTP and FTP. To more easily permit the implementation
of line-based protocols, as well as other protocols that use delimiters, Boost.Asio
includes the functions `read_until()` and `async_read_until()`.
The following example illustrates the use of `async_read_until()` in an HTTP
server, to receive the first line of an HTTP request from a client:
class http_connection
{
...
void start()
{
boost::asio::async_read_until(socket_, data_, "\r\n",
boost::bind(&http_connection::handle_request_line, this, _1));
}
void handle_request_line(boost::system::error_code ec)
{
if (!ec)
{
std::string method, uri, version;
char sp1, sp2, cr, lf;
std::istream is(&data_);
is.unsetf(std::ios_base::skipws);
is >> method >> sp1 >> uri >> sp2 >> version >> cr >> lf;
...
}
}
...
boost::asio::ip::tcp::socket socket_;
boost::asio::streambuf data_;
};
The `streambuf` data member serves as a place to store the data that has been
read from the socket before it is searched for the delimiter. It is important
to remember that there may be additional data ['after] the delimiter. This
surplus data should be left in the `streambuf` so that it may be inspected by a
subsequent call to `read_until()` or `async_read_until()`.
The delimiters may be specified as a single `char`, a `std::string` or a
`boost::regex`. The `read_until()` and `async_read_until()` functions also
include overloads that accept a user-defined function object called a match
condition. For example, to read data into a streambuf until whitespace is
encountered:
typedef boost::asio::buffers_iterator<
boost::asio::streambuf::const_buffers_type> iterator;
std::pair<iterator, bool>
match_whitespace(iterator begin, iterator end)
{
iterator i = begin;
while (i != end)
if (std::isspace(*i++))
return std::make_pair(i, true);
return std::make_pair(i, false);
}
...
boost::asio::streambuf b;
boost::asio::read_until(s, b, match_whitespace);
To read data into a streambuf until a matching character is found:
class match_char
{
public:
explicit match_char(char c) : c_(c) {}
template <typename Iterator>
std::pair<Iterator, bool> operator()(
Iterator begin, Iterator end) const
{
Iterator i = begin;
while (i != end)
if (c_ == *i++)
return std::make_pair(i, true);
return std::make_pair(i, false);
}
private:
char c_;
};
namespace boost { namespace asio {
template <> struct is_match_condition<match_char>
: public boost::true_type {};
} } // namespace boost::asio
...
boost::asio::streambuf b;
boost::asio::read_until(s, b, match_char('a'));
The `is_match_condition<>` type trait automatically evaluates to true for
functions, and for function objects with a nested `result_type` typedef. For
other types the trait must be explicitly specialised, as shown above.
[heading See Also]
[link boost_asio.reference.async_read_until async_read_until()],
[link boost_asio.reference.is_match_condition is_match_condition],
[link boost_asio.reference.read_until read_until()],
[link boost_asio.reference.streambuf streambuf],
[link boost_asio.examples.cpp03_examples.http_client HTTP client example].
[endsect]

View File

@@ -0,0 +1,40 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:model Asynchronous Model]
This section presents a high-level overview of the asynchronous model at the
core of the Boost.Asio library. This model enshrines asynchronous operations as the
fundamental building block of asynchronous composition, but in a way that
decouples them from the composition mechanism. The asynchronous operations in
Boost.Asio support callbacks, futures (both eager and lazy), fibers, coroutines, and
approaches yet to be imagined. This allows the application programmer to select
an approach based on appropriate trade-offs.
* [link boost_asio.overview.model.async_ops Asynchronous Operations]
* [link boost_asio.overview.model.async_agents Asynchronous Agents]
* [link boost_asio.overview.model.associators Associated Characteristics and Associators]
* [link boost_asio.overview.model.child_agents Child Agents]
* [link boost_asio.overview.model.executors Executors]
* [link boost_asio.overview.model.allocators Allocators]
* [link boost_asio.overview.model.cancellation Cancellation]
* [link boost_asio.overview.model.completion_tokens Completion Tokens]
* [link boost_asio.overview.model.library_elements Supporting Library Elements]
* [link boost_asio.overview.model.higher_levels Higher Level Abstractions]
[include model/async_ops.qbk]
[include model/async_agents.qbk]
[include model/associators.qbk]
[include model/child_agents.qbk]
[include model/executors.qbk]
[include model/allocators.qbk]
[include model/cancellation.qbk]
[include model/completion_tokens.qbk]
[include model/library_elements.qbk]
[include model/higher_levels.qbk]
[endsect]

View File

@@ -0,0 +1,65 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:allocators Allocators]
Every asynchronous agent has an associated ['allocator]. An agent's allocator
is an interface used by the agent's asynchronous operations to obtain
['per-operation stable memory] resources (POSMs). This name reflects the fact
that the memory is per-operation because the memory is only retained for the
lifetime of that operation, and stable, because the memory is guaranteed to be
available at that location throughout the operation.
Asynchronous operations may utilise POSMs in a number of different ways:
* The operation doesn't require any POSMs. For example, the operation wraps an
existing API that performs its own memory management, or is copying the long
lived state into existing memory like a circular buffer.
* The operation uses a single, fixed-size POSM for as long as the operation is
outstanding. For example, the operation stores some state in a linked list.
* The operation uses a single, runtime-sized POSM. For example, the operation
stores a copy of a user-supplied buffer, or a runtime-sized array of iovec
structures.
* The operation uses multiple POSMs concurrently. For example, a fixed size
POSM for a linked list plus a runtime-sized POSM for a buffer.
* The operation uses multiple POSMs serially, which may vary in size.
Associated allocators allow users to treat POSM optimisation as a cross-cutting
concern to the composition of asynchronous operations. Furthermore, using
allocators as the interface to obtain POSMs grant substantial flexibility to
both the implementers and users of asynchronous operations:
* Users can ignore the allocator and accept whatever default strategy is
employed by the application.
* Implementers can ignore the allocator, especially if the operation is not
considered performance-sensitive.
* Users can co-locate POSMs for related asynchronous operations, for better
locality of reference.
* For compositions that involve serial POSMs of different sizes, memory usage
need only be as great as the currently extant POSM. For example, consider a
composition that contains a short-lived operation that uses large POSMs
(connection establishment and handshake) followed by a long-lived operation
that uses small POSMs (transferring data to and from the peer).
As noted previously, all resources must be released prior to calling the
completion handler. This enables memory to be recycled for subsequent
asynchronous operations within an agent. This allows applications with
long-lived asynchronous agents to have no hot-path memory allocations, even
though the user code is unaware of associated allocators.
[heading See Also]
[link boost_asio.overview.core.allocation Custom Memory Allocation].
[endsect]

View File

@@ -0,0 +1,78 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:associators Associated Characteristics and Associators]
An asynchronous agent has ['associated characteristics] that specify how
asynchronous operations should behave when composed as part of that agent, such
as:
* An allocator, which determines how the agent's asynchronous operations obtain
memory resources.
* A cancellation slot, which determines how the agent's asynchronous operations
support cancellation.
* An executor, which determines how the agent's completion handlers will be
queued and run.
When an asynchronous operation is run within an asynchronous agent, its
implementation may query these associated characteristics and use them to
satisfy the requirements or preferences they represent. The asynchronous
operation performs these queries by applying ['associator] traits to the
completion handler. Each characteristic has a corresponding associator trait.
An associator trait may be specialised for concrete completion handler types to:
* accept the default characteristic supplied by the asynchronous operation,
returning this default as-is
* return an unrelated implementation of the characteristic, or
* adapt the supplied default to introduce additional behaviour required by the
completion handler.
[heading Specification of an Associator]
Given an associator trait named[footnote The associator traits are named
[link boost_asio.reference.associated_allocator `associated_allocator`],
[link boost_asio.reference.associated_executor `associated_executor`], and
[link boost_asio.reference.associated_cancellation_slot
`associated_cancellation_slot`].] `associated_R`, having:
* a source value `s` of type `S`, in this case the completion handler and its
type,
* a set of type requirements (or a concept) `R` that define the syntactic and
semantic requirements of the associated characteristic, and
* a candidate value `c` of type `C` that meets the type requirements `R`, which
represents a default implementation of the associated characteristic,
supplied by the asynchronous operation
the asynchronous operation uses the associator trait to compute:
* the type `associated_R<S, C>::type`, and
* the value `associated_R<S, C>::get(s, c)`
that meet the requirements defined in `R`. For convenience, these are also
accessible via type alias `associated_R_t<S, C>` and free function
`get_associated_R(s, c)`, respectively.
The trait's primary template is specified such that:
* if `S::R_type` is well-formed, defines a nested type alias type as
`S::R_type`, and a static member function get that returns `s.get_R()`
* otherwise, if `associator<associated_R, S, C>::type` is well-formed and
denotes a type, inherits from `associator<associated_R, S, C>`
* otherwise, defines a nested type alias type as `C`, and a static member
function get that returns `c`.
[endsect]

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

View File

@@ -0,0 +1,35 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:async_agents Asynchronous Agents]
[$boost_asio/async_agent_model.png [width 931px]]
An ['asynchronous agent] is a sequential composition of asynchronous
operations. Every asynchronous operation is considered to run as a part of an
asynchronous agent, even if that agent contains only that single operation. An
asynchronous agent is an entity that may perform work concurrently with other
agents. Asynchronous agents are to asynchronous operations as threads are to
synchronous operations.
However, an asynchronous agent is a purely notional construct that allows us to
reason about the context for, and composition of, asynchronous operations in a
program. The name “asynchronous agent” does not appear in the library, nor is
it important which concrete mechanism[footnote Such as chains of lambdas,
coroutines, fibers, state machines, etc.] is used to compose the asynchronous
operations in an agent.
We can visualise an asynchronous agent as follows:
[$boost_asio/async_agent_chain.png [width 738px]]
Asynchronous agents alternately wait for an asynchronous operation to complete,
and then run a completion handler for that operation. Within the context of an
agent, these completion handlers represent indivisible units of schedulable
work.
[endsect]

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@@ -0,0 +1,81 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:async_ops Asynchronous Operations]
[$boost_asio/async_op_model.png [width 421px]]
An ['asynchronous operation] is the basic unit of composition in the Boost.Asio
asynchronous model. Asynchronous operations represent work that is launched and
performed in the background, while the user's code that initiated the work can
continue with other things.
Conceptually, the lifecycle of an asynchronous operation can be described in
terms of the following events and phases:
[$boost_asio/async_op_phases.png [width 861px]]
An ['initiating function] is a function which may be called by the user to
start an asynchronous operation.
A ['completion handler] is a user-provided, move-only function object that will
be invoked, at most once, with the result of the asynchronous operation. The
invocation of the completion handler tells the user about something that has
already happened: the operation completed, and the side effects of the
operation were established.
The initiating function and completion handler are incorporated into the user's
code as follows:
[$boost_asio/async_op_init_complete.png [width 496px]]
Synchronous operations, being embodied as single functions, have several
inherent semantic properties as a consequence. Asynchronous operations adopt
some of these semantic properties from their synchronous counterparts, in order
to facilitate flexible and efficient composition.
[table
[
[Property of synchronous operations]
[Equivalent property of asynchronous operations]
]
[
[
When a synchronous operation is generic (i.e. a template) the return type
is deterministically derived from the function and its arguments.
]
[
When an asynchronous operation is generic, the completion handler's
arguments' types and order are deterministically derived from the
initiating function and its arguments.
]
]
[
[
If a synchronous operation requires a temporary resource (such as memory,
a file descriptor, or a thread), this resource is released before
returning from the function.
]
[
If an asynchronous operation requires a temporary resource (such as
memory, a file descriptor, or a thread), this resource is released before
calling the completion handler.
]
]
]
The latter is an important property of asynchronous operations, in that it
allows a completion handler to initiate further asynchronous operations without
overlapping resource usage. Consider the trivial (and relatively common) case
of the same operation being repeated over and over in a chain:
[$boost_asio/async_op_trivial_chain.png [width 375px]]
By ensuring that resources are released before the completion handler runs, we
avoid doubling the peak resource usage of the chain of operations.
[endsect]

View File

@@ -0,0 +1,33 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:cancellation Cancellation]
In Boost.Asio, many objects, such as sockets and timers, support object-wide
cancellation of outstanding asynchronous operations via their close or cancel
member functions. However, certain asynchronous operations also support
individual, targeted cancellation. This per-operation cancellation is enabled
by specifying that every asynchronous agent has an associated ['cancellation
slot].
To support cancellation, an asynchronous operation installs a cancellation
handler into the agent's slot. The cancellation handler is a function object
that will be invoked when a cancellation signal is emitted by the user into the
slot. Since a cancellation slot is associated with a single agent, the slot
holds at most one handler at a time, and installing a new handler will
overwrite any previously installed handler. Thus, the same slot is reused for
subsequent asynchronous operations within the agent.
Cancellation is particularly useful when an asynchronous operation contains
multiple child agents. For example, one child agent may be complete and the
other is then cancelled, as its side effects are no longer required.
[heading See Also]
[link boost_asio.overview.core.cancellation Per-Operation Cancellation].
[endsect]

View File

@@ -0,0 +1,56 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:child_agents Child Agents]
The asynchronous operations within an agent may themselves be implemented in
terms of child agents.[footnote In Boost.Asio these asynchronous operations are
referred to as ['composed operations].] As far as the parent agent is
concerned, it is waiting for the completion of a single asynchronous operation.
The asynchronous operations that constitute the child agent run in sequence,
and when the final completion handler runs the parent agent is resumed.
[$boost_asio/async_child_agent_chain.png [width 802px]]
As with individual asynchronous operations, the asynchronous operations built
on child agents must release their temporary resources prior to calling the
completion handler. We may also think of these child agents as resources that
end their lifetimes before the completion handler is invoked.
When an asynchronous operation creates a child agent, it may propagate[footnote
Typically, by specialising the associator trait and forwarding to the outer
completion handler.] the associated characteristics of the parent agent to the
child agent. These associated characteristics may then be recursively
propagated through further layers of asynchronous operations and child agents.
This stacking of asynchronous operations replicates another property of
synchronous operations.
[table
[
[Property of synchronous operations]
[Equivalent property of asynchronous operations]
]
[
[
Compositions of synchronous operations may be refactored to use child
functions that run on the same thread (i.e. are simply called) without
altering functionality.
]
[
Asynchronous agents may be refactored to use asynchronous operations and
child agents that share the associated characteristics of the parent
agent, without altering functionality.
]
]
]
Finally, some asynchronous operations may be implemented in terms of multiple
child agents that run concurrently. In this case, the asynchronous operation
may choose to selectively propagate the associated characteristics of the
parent agent.
[endsect]

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

View File

@@ -0,0 +1,240 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:completion_tokens Completion Tokens]
[$boost_asio/completion_token_model.png [width 436px]]
A key goal of Boost.Asio's asynchronous model is to support multiple composition
mechanisms. This is achieved via a ['completion token], which the user passes
to an asynchronous operation's initiating function to customise the API surface
of the library. By convention, the completion token is the final argument to an
asynchronous operation's initiating function.
For example, if the user passes a lambda (or other function object) as the
completion token, the asynchronous operation behaves as previously described:
the operation begins, and when the operation completes the result is passed to
the lambda.
socket.async_read_some(buffer,
[](error_code e, size_t)
{
// ...
}
);
When the user passes the [link boost_asio.reference.use_future use_future] completion
token, the operation behaves as though implemented in terms of a `promise` and
`future` pair. The initiating function does not just launch the operation, but
also returns a future that may be used to await the result.
future<size_t> f =
socket.async_read_some(
buffer, use_future
);
// ...
size_t n = f.get();
Similarly, when the user passes the [link boost_asio.reference.use_awaitable
use_awaitable] completion token, the initiating function behaves as though it
is an `awaitable`-based coroutine [footnote The [link boost_asio.reference.awaitable
awaitable] class template is included with the Boost.Asio library as a return type
for C++20 coroutines. These coroutines can be trivially implemented in terms of
other `awaitable`-based coroutines.]. However, in this case the initiating
function does not launch the asynchronous operation directly. It only returns
the `awaitable`, which in turn launches the operation when it is co_await-ed.
awaitable<void> foo()
{
size_t n =
co_await socket.async_read_some(
buffer, use_awaitable
);
// ...
}
Finally, the [link boost_asio.reference.yield_context yield_context] completion token
causes the initiating function to behave as a synchronous operation within the
context of a stackful coroutine. It not only begins the asynchronous operation,
but blocks the stackful coroutine until it is complete. From the point of the
stackful coroutine, it is a synchronous operation.
void foo(boost::asio::yield_context yield)
{
size_t n = socket.async_read_some(buffer, yield);
// ...
}
All of these uses are supported by a single implementation of the
`async_read_some` initiating function.
To achieve this, an asynchronous operation must first specify a ['completion
signature] (or, possibly, signatures) that describes the arguments that will be
passed to its completion handler.
Then, the operation's initiating function takes the completion signature,
completion token, and its internal implementation and passes them to the
['async_result] trait. The `async_result` trait is a customisation point that
combines these to first produce a concrete completion handler, and then launch
the operation.
[$boost_asio/completion_token_transform.png [width 856px]]
To see this in practice, let's use a detached thread to adapt a synchronous
operation into an asynchronous one:[footnote For illustrative purposes only.
Not recommended for real world use!]
template <
completion_token_for<void(error_code, size_t)> /*< The `completion_token_for`
concept checks whether
the user-supplied
completion token will
satisfy the specified
completion signature.
For older versions of
C++, simply use `typename`
here instead. >*/
CompletionToken>
auto async_read_some(
tcp::socket& s,
const mutable_buffer& b,
CompletionToken&& token)
{
auto init = []( /*< Define a function object that contains the code to
launch the asynchronous operation. This is passed the
concrete completion handler, followed by any additional
arguments that were passed through the `async_result`
trait. >*/
auto completion_handler,
tcp::socket* s,
const mutable_buffer& b)
{
std::thread( /*< The body of the function object spawns a new thread to
perform the operation. >*/
[](
auto completion_handler,
tcp::socket* s,
const mutable_buffer& b
)
{
error_code ec;
size_t n = s->read_some(b, ec);
std::move(completion_handler)(ec, n); /*< Once the operation
completes, the completion
handler is passed the
result. >*/
},
std::move(completion_handler),
s,
b
).detach();
};
return async_result< /*< The `async_result` trait is passed the (decayed)
completion token type, and the completion
signatures of the asynchronous operation. >*/
decay_t<CompletionToken>,
void(error_code, size_t)
>::initiate(
init, /*< Call the traits `initiate` member function, first passing
the function object that launches the operation. >*/
std::forward<CompletionToken>(token), /*< Next comes the forwarded
completion token. The trait
implementation will convert
this into a concrete
completion handler. >*/
&s, /*< Finally, pass any additional arguments for the function
object. Assume that these may be decay-copied and moved by the
trait implementation. >*/
b
);
}
In practice we should call the [link boost_asio.reference.async_initiate
async_initiate] helper function, rather than use the `async_result` trait
directly. The `async_initiate` function automatically performs the necessary
decay and forward of the completion token, and also enables backwards
compatibility with legacy completion token implementations.
template <
completion_token_for<void(error_code, size_t)>
CompletionToken>
auto async_read_some(
tcp::socket& s,
const mutable_buffer& b,
CompletionToken&& token)
{
auto init = /* ... as above ... */;
return async_initiate<
CompletionToken,
void(error_code, size_t)
>(init, token, &s, b);
}
We can think of the completion token as a kind of proto completion handler. In
the case where we pass a function object (like a lambda) as the completion
token, it already satisfies the completion handler requirements. The
async_result primary template handles this case by trivially forwarding the
arguments through:
template <class CompletionToken, completion_signature... Signatures>
struct async_result
{
template <
class Initiation,
completion_handler_for<Signatures...> CompletionHandler,
class... Args>
static void initiate(
Initiation&& initiation,
CompletionHandler&& completion_handler,
Args&&... args)
{
std::forward<Initiation>(initiation)(
std::forward<CompletionHandler>(completion_handler),
std::forward<Args>(args)...);
}
};
We can see here that this default implementation avoids copies of all
arguments, thus ensuring that eager initiation is as efficient as possible.
On the other hand, a lazy completion token (such as `use_awaitable` above) may
capture these arguments for deferred launching of the operation. For example, a
specialisation for a trivial [link boost_asio.reference.experimental__deferred
deferred] token (that simply packages the operation for later) might look
something like this:
template <completion_signature... Signatures>
struct async_result<deferred_t, Signatures...>
{
template <class Initiation, class... Args>
static auto initiate(Initiation initiation, deferred_t, Args... args)
{
return [
initiation = std::move(initiation),
arg_pack = std::make_tuple(std::move(args)...)
](auto&& token) mutable
{
return std::apply(
[&](auto&&... args)
{
return async_result<decay_t<decltype(token)>, Signatures...>::initiate(
std::move(initiation),
std::forward<decltype(token)>(token),
std::forward<decltype(args)>(args)...
);
},
std::move(arg_pack)
);
};
}
};
[endsect]

View File

@@ -0,0 +1,55 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:executors Executors]
Every asynchronous agent has an associated ['executor]. An agent's executor
determines how the agent's completion handlers are queued and ultimately run.
Example uses of executors include:
* Coordinating a group of asynchronous agents that operate on shared data
structures, ensuring that the agents' completion handlers never run
concurrently[footnote In Boost.Asio, this kind of executor is called a [link
boost_asio.overview.core.strands strand].].
* Ensuring that agents are run on specified execution resource (e.g. a CPU)
that is proximal to data or an event source (e.g. a NIC).
* Denoting a group of related agents, and so enabling dynamic thread pools to
make smarter scheduling decisions (such as moving the agents between
execution resources as a unit).
* Queuing all completion handlers to run on a GUI application thread, so that
they may safely update user interface elements.
* Returning an asynchronous operation's default executor as-is, to run
completion handlers as close as possible to the event that triggered the
operation's completion.
* Adapting an asynchronous operation's default executor, to run code before and
after every completion handler, such as logging, user authorisation, or
exception handling.
* Specifying a priority for an asynchronous agent and its completion handlers.
The asynchronous operations within an asynchronous agent use the agent's
associated executor to:
* Track the existence of the work that the asynchronous operation represents,
while the operation is outstanding.
* Enqueue the completion handler for execution on completion of an operation.
* Ensure that completion handlers do not run re-entrantly, if doing so might
lead to inadvertent recursion and stack overflow.
Thus, an asynchronous agent's associated executor represents a policy of how,
where, and when the agent should run, specified as a cross-cutting concern to
the code that makes up the agent.
[endsect]

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

View File

@@ -0,0 +1,40 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:higher_levels Higher Level Abstractions]
[$boost_asio/higher_level_model.png [width 940px]]
The asynchronous model presented in this section provides a basis for defining
higher level abstractions. Boost.Asio builds on this core model to provide additional
facilities, such as:
* I/O objects such as [link boost_asio.overview.networking sockets] and [link
boost_asio.overview.timers timers] that expose asynchronous operations on top of
this model.
* Concrete executors, such as the [link boost_asio.reference.io_context io_context]
executor, [link boost_asio.reference.thread_pool thread_pool] executor, and the
[link boost_asio.reference.strand strand] adapter which guarantees non-concurrent
execution of completion handlers.
* Completion tokens that facilitate different composition mechanisms, such as
[link boost_asio.overview.composition.cpp20_coroutines C++ coroutines], [link
boost_asio.overview.composition.spawn stackful coroutines], [link
boost_asio.overview.cpp2011.futures futures], and [link
boost_asio.reference.experimental__deferred deferred operations].
* High level support for C++ coroutines that combines support executors and
cancellation slots to allow for [link
boost_asio.overview.composition.cpp20_coroutines.co_ordinating_parallel_coroutines
easy coordination of concurrent asynchronous agents].
To allow users to more easily write their own asynchronous operations that
adhere to this model, Boost.Asio also provides the helper function [link
boost_asio.reference.async_compose async_compose].
[endsect]

View File

@@ -0,0 +1,102 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:library_elements Supporting Library Elements]
The Boost.Asio asynchronous model is enabled by the library elements listed in the
table below.
[table
[
[Library Element]
[Description]
]
[
[
`completion_signature` concept
]
[
Defines valid completion signature forms.
]
]
[
[
`completion_handler_for` concept
]
[
Determines whether a completion handler is callable with a given set of
completion signatures.
]
]
[
[
[link boost_asio.reference.async_result async_result] trait
]
[
Converts a completion signature and completion token into a concrete
completion handler, and launches the operation.
]
]
[
[
[link boost_asio.reference.async_initiate async_initiate] function
]
[
Helper function to simplify use of the `async_result` trait.
]
]
[
[
`completion_token_for` concept
]
[
Determines whether a completion token produces a completion handler for a
given set of completion signatures.
]
]
[
[
[link boost_asio.reference.associator associator] trait
]
[
Automatically propagates all associators through layers of abstraction.
]
]
[
[
[link boost_asio.reference.associated_executor associated_executor] trait,
`associated_executor_t` type alias, and [link
boost_asio.reference.get_associated_executor get_associated_executor] function
]
[
Defines an asynchronous agents associated executor.
]
]
[
[
[link boost_asio.reference.associated_allocator associated_allocator] trait,
`associated_allocator_t` type alias, and [link
boost_asio.reference.get_associated_allocator get_associated_allocator] function
]
[
Defines an asynchronous agents associated allocator.
]
]
[
[
[link boost_asio.reference.associated_cancellation_slot
associated_cancellation_slot] trait, `associated_cancellation_slot_t`
type alias, and [link boost_asio.reference.get_associated_cancellation_slot
get_associated_cancellation_slot] function
]
[
Defines an asynchronous agents associated cancellation slot.
]
]
]
[endsect]

View File

@@ -0,0 +1,94 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:other_protocols Support for Other Protocols]
Support for other socket protocols (such as Bluetooth or IRCOMM sockets) can be
added by implementing the [link boost_asio.reference.Protocol protocol type
requirements]. However, in many cases these protocols may also be used with
Boost.Asio's generic protocol support. For this, Boost.Asio provides the following four
classes:
* [link boost_asio.reference.generic__datagram_protocol `generic::datagram_protocol`]
* [link boost_asio.reference.generic__raw_protocol `generic::raw_protocol`]
* [link boost_asio.reference.generic__seq_packet_protocol `generic::seq_packet_protocol`]
* [link boost_asio.reference.generic__stream_protocol `generic::stream_protocol`]
These classes implement the [link boost_asio.reference.Protocol protocol type
requirements], but allow the user to specify the address family (e.g. `AF_INET`)
and protocol type (e.g. `IPPROTO_TCP`) at runtime. For example:
boost::asio::generic::stream_protocol::socket my_socket(my_io_context);
my_socket.open(boost::asio::generic::stream_protocol(AF_INET, IPPROTO_TCP));
...
An endpoint class template, [link boost_asio.reference.generic__basic_endpoint
`boost::asio::generic::basic_endpoint`], is included to support these protocol
classes. This endpoint can hold any other endpoint type, provided its native
representation fits into a `sockaddr_storage` object. This class will also
convert from other types that implement the [link boost_asio.reference.Endpoint
endpoint] type requirements:
boost::asio::ip::tcp::endpoint my_endpoint1 = ...;
boost::asio::generic::stream_protocol::endpoint my_endpoint2(my_endpoint1);
The conversion is implicit, so as to support the following use cases:
boost::asio::generic::stream_protocol::socket my_socket(my_io_context);
boost::asio::ip::tcp::endpoint my_endpoint = ...;
my_socket.connect(my_endpoint);
[heading C++11 Move Construction]
When using C++11, it is possible to perform move construction from a socket (or
acceptor) object to convert to the more generic protocol's socket (or acceptor)
type. If the protocol conversion is valid:
Protocol1 p1 = ...;
Protocol2 p2(p1);
then the corresponding socket conversion is allowed:
Protocol1::socket my_socket1(my_io_context);
...
Protocol2::socket my_socket2(std::move(my_socket1));
For example, one possible conversion is from a TCP socket to a generic
stream-oriented socket:
boost::asio::ip::tcp::socket my_socket1(my_io_context);
...
boost::asio::generic::stream_protocol::socket my_socket2(std::move(my_socket1));
These conversions are also available for move-assignment.
These conversions are not limited to the above generic protocol classes.
User-defined protocols may take advantage of this feature by similarly ensuring
the conversion from `Protocol1` to `Protocol2` is valid, as above.
[heading Accepting Generic Sockets]
As a convenience, a socket acceptor's `accept()` and `async_accept()` functions
can directly accept into a different protocol's socket type, provided the
corresponding protocol conversion is valid. For example, the following is
supported because the protocol `boost::asio::ip::tcp` is convertible to
`boost::asio::generic::stream_protocol`:
boost::asio::ip::tcp::acceptor my_acceptor(my_io_context);
...
boost::asio::generic::stream_protocol::socket my_socket(my_io_context);
my_acceptor.accept(my_socket);
[heading See Also]
[link boost_asio.reference.generic__datagram_protocol `generic::datagram_protocol`],
[link boost_asio.reference.generic__raw_protocol `generic::raw_protocol`],
[link boost_asio.reference.generic__seq_packet_protocol `generic::seq_packet_protocol`],
[link boost_asio.reference.generic__stream_protocol `generic::stream_protocol`],
[link boost_asio.reference.Protocol protocol type requirements].
[endsect]

View File

@@ -0,0 +1,152 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:posix POSIX-Specific Functionality]
[link boost_asio.overview.posix.local UNIX Domain Sockets]
[link boost_asio.overview.posix.stream_descriptor Stream-Oriented File Descriptors]
[link boost_asio.overview.posix.fork Fork]
[section:local UNIX Domain Sockets]
Boost.Asio provides basic support for UNIX domain sockets (also known as local
sockets). The simplest use involves creating a pair of connected sockets.
The following code:
local::stream_protocol::socket socket1(my_io_context);
local::stream_protocol::socket socket2(my_io_context);
local::connect_pair(socket1, socket2);
will create a pair of stream-oriented sockets. To do the same for
datagram-oriented sockets, use:
local::datagram_protocol::socket socket1(my_io_context);
local::datagram_protocol::socket socket2(my_io_context);
local::connect_pair(socket1, socket2);
A UNIX domain socket server may be created by binding an acceptor to an
endpoint, in much the same way as one does for a TCP server:
::unlink("/tmp/foobar"); // Remove previous binding.
local::stream_protocol::endpoint ep("/tmp/foobar");
local::stream_protocol::acceptor acceptor(my_io_context, ep);
local::stream_protocol::socket socket(my_io_context);
acceptor.accept(socket);
A client that connects to this server might look like:
local::stream_protocol::endpoint ep("/tmp/foobar");
local::stream_protocol::socket socket(my_io_context);
socket.connect(ep);
Transmission of file descriptors or credentials across UNIX domain sockets is
not directly supported within Boost.Asio, but may be achieved by accessing the
socket's underlying descriptor using the [link
boost_asio.reference.basic_socket.native_handle native_handle()] member function.
[heading See Also]
[link boost_asio.reference.local__connect_pair local::connect_pair],
[link boost_asio.reference.local__datagram_protocol local::datagram_protocol],
[link boost_asio.reference.local__datagram_protocol.endpoint local::datagram_protocol::endpoint],
[link boost_asio.reference.local__datagram_protocol.socket local::datagram_protocol::socket],
[link boost_asio.reference.local__stream_protocol local::stream_protocol],
[link boost_asio.reference.local__stream_protocol.acceptor local::stream_protocol::acceptor],
[link boost_asio.reference.local__stream_protocol.endpoint local::stream_protocol::endpoint],
[link boost_asio.reference.local__stream_protocol.iostream local::stream_protocol::iostream],
[link boost_asio.reference.local__stream_protocol.socket local::stream_protocol::socket],
[link boost_asio.examples.cpp03_examples.unix_domain_sockets UNIX domain sockets examples].
[heading Notes]
UNIX domain sockets are only available at compile time if supported by the
target operating system. A program may test for the macro
`BOOST_ASIO_HAS_LOCAL_SOCKETS` to determine whether they are supported.
[endsect]
[section:stream_descriptor Stream-Oriented File Descriptors]
Boost.Asio includes classes added to permit synchronous and asynchronous read and
write operations to be performed on POSIX file descriptors, such as pipes,
standard input and output, and various devices.
These classes also provide limited support for regular files. This support
assumes that the underlying read and write operations provided by the operating
system never fail with `EAGAIN` or `EWOULDBLOCK`. (This assumption normally
holds for buffered file I/O.) Synchronous and asynchronous read and write
operations on file descriptors will succeed but the I/O will always be
performed immediately. Wait operations, and operations involving
`boost::asio::null_buffers`, are not portably supported.
For example, to perform read and write operations on standard input
and output, the following objects may be created:
posix::stream_descriptor in(my_io_context, ::dup(STDIN_FILENO));
posix::stream_descriptor out(my_io_context, ::dup(STDOUT_FILENO));
These are then used as synchronous or asynchronous read and write streams. This
means the objects can be used with any of the [link boost_asio.reference.read
read()], [link boost_asio.reference.async_read async_read()], [link
boost_asio.reference.write write()], [link boost_asio.reference.async_write async_write()],
[link boost_asio.reference.read_until read_until()] or [link
boost_asio.reference.async_read_until async_read_until()] free functions.
[heading See Also]
[link boost_asio.reference.posix__stream_descriptor posix::stream_descriptor],
[link boost_asio.examples.cpp03_examples.chat Chat example (C++03)],
[link boost_asio.examples.cpp11_examples.chat Chat example (C++11)].
[heading Notes]
POSIX stream descriptors are only available at compile time if supported by the
target operating system. A program may test for the macro
`BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR` to determine whether they are supported.
[endsect]
[section:fork Fork]
Boost.Asio supports programs that utilise the `fork()` system call. Provided the
program calls `io_context.notify_fork()` at the appropriate times, Boost.Asio will
recreate any internal file descriptors (such as the "self-pipe trick"
descriptor used for waking up a reactor). The notification is usually performed
as follows:
io_context_.notify_fork(boost::asio::io_context::fork_prepare);
if (fork() == 0)
{
io_context_.notify_fork(boost::asio::io_context::fork_child);
...
}
else
{
io_context_.notify_fork(boost::asio::io_context::fork_parent);
...
}
User-defined services can also be made fork-aware by overriding the
`io_context::service::notify_fork()` virtual function.
Note that any file descriptors accessible via Boost.Asio's public API (e.g. the
descriptors underlying `basic_socket<>`, `posix::stream_descriptor`, etc.) are
not altered during a fork. It is the program's responsibility to manage these
as required.
[heading See Also]
[link boost_asio.reference.io_context.notify_fork io_context::notify_fork()],
[link boost_asio.reference.io_context.fork_event io_context::fork_event],
[link boost_asio.reference.execution_context__service.notify_fork io_context::service::notify_fork()],
[link boost_asio.examples.cpp03_examples.fork Fork examples].
[endsect]
[endsect]

View File

@@ -0,0 +1,100 @@
digraph g
{
edge
[
fontname="Helvetica",
fontsize=10,
labelfontname="Helvetica",
labelfontsize=10
];
node
[
fontname="Helvetica",
fontsize=10,
shape=record
];
initiator
[
label="Initiator"
];
async_processor
[
label="Asynchronous\nOperation Processor"
];
async_op
[
label="Asynchronous\nOperation"
];
completion_queue
[
label="Completion\nEvent Queue"
];
async_event_demuxer
[
label="Asynchronous\nEvent Demultiplexer"
];
proactor
[
label="Proactor"
];
handler
[
label="Completion\nHandler"
];
initiator -> async_processor
[
label="uses",
style="dashed"
];
initiator -> async_op
[
label="starts",
style="dashed"
];
initiator -> handler
[
label="creates",
style="dashed"
];
async_processor -> async_op
[
label="executes",
style="dashed"
];
async_processor -> completion_queue
[
label="enqueues",
style="dashed"
];
async_op -> handler;
async_event_demuxer -> completion_queue
[
label="dequeues",
style="dashed"
];
proactor -> async_event_demuxer
[
];
proactor -> handler
[
label="demultiplexes\n& dispatches"
style="dashed"
];
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,149 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:protocols TCP, UDP and ICMP]
Boost.Asio provides off-the-shelf support for the internet protocols TCP, UDP and
ICMP.
[heading TCP Clients]
Hostname resolution is performed using a resolver, where host and service names
are looked up and converted into one or more endpoints:
ip::tcp::resolver resolver(my_io_context);
ip::tcp::resolver::query query("www.boost.org", "http");
ip::tcp::resolver::iterator iter = resolver.resolve(query);
ip::tcp::resolver::iterator end; // End marker.
while (iter != end)
{
ip::tcp::endpoint endpoint = *iter++;
std::cout << endpoint << std::endl;
}
The list of endpoints obtained above could contain both IPv4 and IPv6 endpoints,
so a program should try each of them until it finds one that works. This keeps the
client program independent of a specific IP version.
To simplify the development of protocol-independent programs, TCP clients may
establish connections using the free functions [link boost_asio.reference.connect
connect()] and [link boost_asio.reference.async_connect async_connect()]. These
operations try each endpoint in a list until the socket is successfully
connected. For example, a single call:
ip::tcp::socket socket(my_io_context);
boost::asio::connect(socket, resolver.resolve(query));
will synchronously try all endpoints until one is successfully connected.
Similarly, an asynchronous connect may be performed by writing:
boost::asio::async_connect(socket_, iter,
boost::bind(&client::handle_connect, this,
boost::asio::placeholders::error));
// ...
void handle_connect(const error_code& error)
{
if (!error)
{
// Start read or write operations.
}
else
{
// Handle error.
}
}
When a specific endpoint is available, a socket can be created and connected:
ip::tcp::socket socket(my_io_context);
socket.connect(endpoint);
Data may be read from or written to a connected TCP socket using the [link
boost_asio.reference.basic_stream_socket.receive receive()], [link
boost_asio.reference.basic_stream_socket.async_receive async_receive()], [link
boost_asio.reference.basic_stream_socket.send send()] or [link
boost_asio.reference.basic_stream_socket.async_send async_send()] member functions.
However, as these could result in [link boost_asio.overview.core.streams short writes
or reads], an application will typically use the following operations instead:
[link boost_asio.reference.read read()], [link boost_asio.reference.async_read
async_read()], [link boost_asio.reference.write write()] and [link
boost_asio.reference.async_write async_write()].
[heading TCP Servers]
A program uses an acceptor to accept incoming TCP connections:
ip::tcp::acceptor acceptor(my_io_context, my_endpoint);
...
ip::tcp::socket socket(my_io_context);
acceptor.accept(socket);
After a socket has been successfully accepted, it may be read from or written
to as illustrated for TCP clients above.
[heading UDP]
UDP hostname resolution is also performed using a resolver:
ip::udp::resolver resolver(my_io_context);
ip::udp::resolver::query query("localhost", "daytime");
ip::udp::resolver::iterator iter = resolver.resolve(query);
...
A UDP socket is typically bound to a local endpoint. The following code will
create an IP version 4 UDP socket and bind it to the "any" address on port
`12345`:
ip::udp::endpoint endpoint(ip::udp::v4(), 12345);
ip::udp::socket socket(my_io_context, endpoint);
Data may be read from or written to an unconnected UDP socket using the [link
boost_asio.reference.basic_datagram_socket.receive_from receive_from()], [link
boost_asio.reference.basic_datagram_socket.async_receive_from async_receive_from()],
[link boost_asio.reference.basic_datagram_socket.send_to send_to()] or [link
boost_asio.reference.basic_datagram_socket.async_send_to async_send_to()] member
functions. For a connected UDP socket, use the [link
boost_asio.reference.basic_datagram_socket.receive receive()], [link
boost_asio.reference.basic_datagram_socket.async_receive async_receive()], [link
boost_asio.reference.basic_datagram_socket.send send()] or [link
boost_asio.reference.basic_datagram_socket.async_send async_send()] member functions.
[heading ICMP]
As with TCP and UDP, ICMP hostname resolution is performed using a resolver:
ip::icmp::resolver resolver(my_io_context);
ip::icmp::resolver::query query("localhost", "");
ip::icmp::resolver::iterator iter = resolver.resolve(query);
...
An ICMP socket may be bound to a local endpoint. The following code will create
an IP version 6 ICMP socket and bind it to the "any" address:
ip::icmp::endpoint endpoint(ip::icmp::v6(), 0);
ip::icmp::socket socket(my_io_context, endpoint);
The port number is not used for ICMP.
Data may be read from or written to an unconnected ICMP socket using the [link
boost_asio.reference.basic_raw_socket.receive_from receive_from()], [link
boost_asio.reference.basic_raw_socket.async_receive_from async_receive_from()],
[link boost_asio.reference.basic_raw_socket.send_to send_to()] or [link
boost_asio.reference.basic_raw_socket.async_send_to async_send_to()] member
functions.
[heading See Also]
[link boost_asio.reference.ip__tcp ip::tcp],
[link boost_asio.reference.ip__udp ip::udp],
[link boost_asio.reference.ip__icmp ip::icmp],
[link boost_asio.tutorial.tutdaytime1 daytime protocol tutorials],
[link boost_asio.examples.cpp03_examples.icmp ICMP ping example].
[endsect]

View File

@@ -0,0 +1,54 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:rationale Rationale]
Most programs interact with the outside world in some way, whether it be via a
file, a network, a serial cable, or the console. Sometimes, as is the case with
networking, individual I/O operations can take a long time to complete. This
poses particular challenges to application development.
Boost.Asio provides the tools to manage these long running operations, without
requiring programs to use concurrency models based on threads and explicit
locking.
The Boost.Asio library is intended for programmers using C++ for systems programming,
where access to operating system functionality such as networking is often
required. In particular, Boost.Asio addresses the following goals:
* [*Portability.] The library should support a range of commonly used operating
systems, and provide consistent behaviour across these operating systems.
* [*Scalability.] The library should facilitate the development of network
applications that scale to thousands of concurrent connections. The library
implementation for each operating system should use the mechanism that best
enables this scalability.
* [*Efficiency.] The library should support techniques such as scatter-gather
I/O, and allow programs to minimise data copying.
* [*Model concepts from established APIs, such as BSD sockets.] The
BSD socket API is widely implemented and understood, and is covered in much
literature. Other programming languages often use a similar interface for
networking APIs. As far as is reasonable, Boost.Asio should leverage existing
practice.
* [*Ease of use.] The library should provide a lower entry barrier for new
users by taking a toolkit, rather than framework, approach. That is, it should
try to minimise the up-front investment in time to just learning a few basic
rules and guidelines. After that, a library user should only need to understand
the specific functions that are being used.
* [*Basis for further abstraction.] The library should permit the development
of other libraries that provide higher levels of abstraction. For example,
implementations of commonly used protocols such as HTTP.
Although Boost.Asio started life focused primarily on networking, its concepts of
asynchronous I/O have been extended to include other operating system resources
such as serial ports, file descriptors, and so on.
[endsect]

View File

@@ -0,0 +1,44 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:reactor Reactor-Style Operations]
Sometimes a program must be integrated with a third-party library that wants to
perform the I/O operations itself. To facilitate this, Boost.Asio includes
synchronous and asynchronous operations that may be used to wait for a socket
to become ready to read, ready to write, or to have a pending error condition.
As an example, to perform a non-blocking read something like the following may
be used:
ip::tcp::socket socket(my_io_context);
...
socket.non_blocking(true);
...
socket.async_wait(ip::tcp::socket::wait_read, read_handler);
...
void read_handler(boost::system::error_code ec)
{
if (!ec)
{
std::vector<char> buf(socket.available());
socket.read_some(buffer(buf));
}
}
These operations are supported for sockets on all platforms, and for the POSIX
stream-oriented descriptor classes.
[heading See Also]
[link boost_asio.reference.basic_socket.wait basic_socket::wait()],
[link boost_asio.reference.basic_socket.async_wait basic_socket::async_wait()],
[link boost_asio.reference.basic_socket.non_blocking basic_socket::non_blocking()],
[link boost_asio.reference.basic_socket.native_non_blocking basic_socket::native_non_blocking()],
[link boost_asio.examples.cpp03_examples.nonblocking nonblocking example].
[endsect]

View File

@@ -0,0 +1,45 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:serial_ports Serial Ports]
Boost.Asio includes classes for creating and manipulating serial ports in a portable
manner. For example, a serial port may be opened using:
serial_port port(my_io_context, name);
where name is something like `"COM1"` on Windows, and `"/dev/ttyS0"` on POSIX
platforms.
Once opened, the serial port may be used as a [link boost_asio.overview.core.streams
stream]. This means the objects can be used with any of the [link
boost_asio.reference.read read()], [link boost_asio.reference.async_read async_read()],
[link boost_asio.reference.write write()], [link boost_asio.reference.async_write
async_write()], [link boost_asio.reference.read_until read_until()] or [link
boost_asio.reference.async_read_until async_read_until()] free functions.
The serial port implementation also includes option classes for configuring the
port's baud rate, flow control type, parity, stop bits and character size.
[heading See Also]
[link boost_asio.reference.serial_port serial_port],
[link boost_asio.reference.serial_port_base serial_port_base],
[link boost_asio.reference.serial_port_base__baud_rate serial_port_base::baud_rate],
[link boost_asio.reference.serial_port_base__flow_control serial_port_base::flow_control],
[link boost_asio.reference.serial_port_base__parity serial_port_base::parity],
[link boost_asio.reference.serial_port_base__stop_bits serial_port_base::stop_bits],
[link boost_asio.reference.serial_port_base__character_size serial_port_base::character_size].
[heading Notes]
Serial ports are available on all POSIX platforms. For Windows, serial ports
are only available at compile time when the I/O completion port backend is used
(which is the default). A program may test for the macro
`BOOST_ASIO_HAS_SERIAL_PORT` to determine whether they are supported.
[endsect]

View File

@@ -0,0 +1,44 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:signals Signal Handling]
Boost.Asio supports signal handling using a class called [link
boost_asio.reference.signal_set signal_set]. Programs may add one or more signals to
the set, and then perform an `async_wait()` operation. The specified handler
will be called when one of the signals occurs. The same signal number may be
registered with multiple [link boost_asio.reference.signal_set signal_set] objects,
however the signal number must be used only with Boost.Asio.
void handler(
const boost::system::error_code& error,
int signal_number)
{
if (!error)
{
// A signal occurred.
}
}
...
// Construct a signal set registered for process termination.
boost::asio::signal_set signals(io_context, SIGINT, SIGTERM);
// Start an asynchronous wait for one of the signals to occur.
signals.async_wait(handler);
Signal handling also works on Windows, as the Microsoft Visual C++ runtime
library maps console events like Ctrl+C to the equivalent signal.
[heading See Also]
[link boost_asio.reference.signal_set signal_set],
[link boost_asio.examples.cpp03_examples.http_server HTTP server example (C++03)],
[link boost_asio.examples.cpp11_examples.http_server HTTP server example (C++11)].
[endsect]

View File

@@ -0,0 +1,102 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:spawn Stackful Coroutines]
The [link boost_asio.reference.spawn `spawn()`] function is a high-level wrapper for
running stackful coroutines. It is based on the Boost.Coroutine library. The
`spawn()` function enables programs to implement asynchronous logic in a
synchronous manner, as shown in the following example:
boost::asio::spawn(my_strand, do_echo);
// ...
void do_echo(boost::asio::yield_context yield)
{
try
{
char data[128];
for (;;)
{
std::size_t length =
my_socket.async_read_some(
boost::asio::buffer(data), yield);
boost::asio::async_write(my_socket,
boost::asio::buffer(data, length), yield);
}
}
catch (std::exception& e)
{
// ...
}
}
The first argument to `spawn()` may be a
[link boost_asio.reference.io_context__strand `strand`],
[link boost_asio.reference.io_context `io_context`], or a
[link boost_asio.reference.Handler completion handler].
This argument determines the context in which the coroutine is permitted to
execute. For example, a server's per-client object may consist of multiple
coroutines; they should all run on the same `strand` so that no explicit
synchronisation is required.
The second argument is a function object with signature:
void coroutine(boost::asio::yield_context yield);
that specifies the code to be run as part of the coroutine. The parameter
`yield` may be passed to an asynchronous operation in place of the completion
handler, as in:
std::size_t length =
my_socket.async_read_some(
boost::asio::buffer(data), yield);
This starts the asynchronous operation and suspends the coroutine. The
coroutine will be resumed automatically when the asynchronous operation
completes.
Where an asynchronous operation's handler signature has the form:
void handler(boost::system::error_code ec, result_type result);
the initiating function returns the result_type. In the `async_read_some`
example above, this is `size_t`. If the asynchronous operation fails, the
`error_code` is converted into a `system_error` exception and thrown.
Where a handler signature has the form:
void handler(boost::system::error_code ec);
the initiating function returns `void`. As above, an error is passed back to
the coroutine as a `system_error` exception.
To collect the `error_code` from an operation, rather than have it throw an
exception, associate the output variable with the `yield_context` as follows:
boost::system::error_code ec;
std::size_t length =
my_socket.async_read_some(
boost::asio::buffer(data), yield[ec]);
[*Note:] if `spawn()` is used with a custom completion handler of type
`Handler`, the function object signature is actually:
void coroutine(boost::asio::basic_yield_context<Handler> yield);
[heading See Also]
[link boost_asio.reference.spawn spawn],
[link boost_asio.reference.yield_context yield_context],
[link boost_asio.reference.basic_yield_context basic_yield_context],
[link boost_asio.examples.cpp03_examples.spawn Spawn example (C++03)],
[link boost_asio.examples.cpp11_examples.spawn Spawn example (C++11)],
[link boost_asio.overview.composition.coroutine Stackless Coroutines].
[endsect]

View File

@@ -0,0 +1,124 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:ssl SSL]
Boost.Asio contains classes and class templates for basic SSL support. These classes
allow encrypted communication to be layered on top of an existing stream, such
as a TCP socket.
Before creating an encrypted stream, an application must construct an SSL
context object. This object is used to set SSL options such as verification
mode, certificate files, and so on. As an illustration, client-side
initialisation may look something like:
ssl::context ctx(ssl::context::sslv23);
ctx.set_verify_mode(ssl::verify_peer);
ctx.load_verify_file("ca.pem");
To use SSL with a TCP socket, one may write:
ssl::stream<ip::tcp::socket> ssl_sock(my_io_context, ctx);
To perform socket-specific operations, such as establishing an outbound
connection or accepting an incoming one, the underlying socket must first be
obtained using the `ssl::stream` template's [link
boost_asio.reference.ssl__stream.lowest_layer `lowest_layer()`] member function:
ip::tcp::socket::lowest_layer_type& sock = ssl_sock.lowest_layer();
sock.connect(my_endpoint);
In some use cases the underlying stream object will need to have a longer
lifetime than the SSL stream, in which case the template parameter should be a
reference to the stream type:
ip::tcp::socket sock(my_io_context);
ssl::stream<ip::tcp::socket&> ssl_sock(sock, ctx);
SSL handshaking must be performed prior to transmitting or receiving data over
an encrypted connection. This is accomplished using the `ssl::stream`
template's [link boost_asio.reference.ssl__stream.handshake handshake()] or [link
boost_asio.reference.ssl__stream.async_handshake async_handshake()] member functions.
Once connected, SSL stream objects are used as synchronous or asynchronous read
and write streams. This means the objects can be used with any of the [link
boost_asio.reference.read read()], [link boost_asio.reference.async_read async_read()],
[link boost_asio.reference.write write()], [link boost_asio.reference.async_write
async_write()], [link boost_asio.reference.read_until read_until()] or [link
boost_asio.reference.async_read_until async_read_until()] free functions.
[heading Certificate Verification]
Boost.Asio provides various methods for configuring the way SSL certificates are
verified:
* [link boost_asio.reference.ssl__context.set_default_verify_paths ssl::context::set_default_verify_paths()]
* [link boost_asio.reference.ssl__context.set_verify_mode ssl::context::set_verify_mode()]
* [link boost_asio.reference.ssl__context.set_verify_callback ssl::context::set_verify_callback()]
* [link boost_asio.reference.ssl__context.load_verify_file ssl::context::load_verify_file()]
* [link boost_asio.reference.ssl__stream.set_verify_mode ssl::stream::set_verify_mode()]
* [link boost_asio.reference.ssl__stream.set_verify_callback ssl::stream::set_verify_callback()]
To simplify use cases where certificates are verified according to the rules in
RFC 6125 (identity verification in the context of Transport Layer Security),
Boost.Asio provides a reusable verification callback as a function object:
* [link boost_asio.reference.ssl__host_name_verification ssl::host_name_verification]
The following example shows verification of a remote host's certificate
according to the rules used by HTTPS:
using boost::asio::ip::tcp;
namespace ssl = boost::asio::ssl;
typedef ssl::stream<tcp::socket> ssl_socket;
// Create a context that uses the default paths for
// finding CA certificates.
ssl::context ctx(ssl::context::sslv23);
ctx.set_default_verify_paths();
// Open a socket and connect it to the remote host.
boost::asio::io_context io_context;
ssl_socket sock(io_context, ctx);
tcp::resolver resolver(io_context);
tcp::resolver::query query("host.name", "https");
boost::asio::connect(sock.lowest_layer(), resolver.resolve(query));
sock.lowest_layer().set_option(tcp::no_delay(true));
// Perform SSL handshake and verify the remote host's
// certificate.
sock.set_verify_mode(ssl::verify_peer);
sock.set_verify_callback(ssl::host_name_verification("host.name"));
sock.handshake(ssl_socket::client);
// ... read and write as normal ...
[heading SSL and Threads]
SSL stream objects perform no locking of their own. Therefore, it is essential
that all asynchronous SSL operations are performed in an implicit or explicit
[link boost_asio.overview.core.strands strand]. Note that this means that no
synchronisation is required (and so no locking overhead is incurred) in single
threaded programs.
[heading See Also]
[link boost_asio.reference.ssl__context ssl::context],
[link boost_asio.reference.ssl__host_name_verification ssl::host_name_verification],
[link boost_asio.reference.ssl__stream ssl::stream],
[link boost_asio.examples.cpp03_examples.ssl SSL example (C++03)],
[link boost_asio.examples.cpp11_examples.ssl SSL example (C++11)].
[heading Notes]
[@http://www.openssl.org OpenSSL] is required to make use of Boost.Asio's SSL
support. When an application needs to use OpenSSL functionality that is not
wrapped by Boost.Asio, the underlying OpenSSL types may be obtained by calling [link
boost_asio.reference.ssl__context.native_handle `ssl::context::native_handle()`] or
[link boost_asio.reference.ssl__stream.native_handle `ssl::stream::native_handle()`].
[endsect]

View File

@@ -0,0 +1,114 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:strands Strands: Use Threads Without Explicit Locking]
A strand is defined as a strictly sequential invocation of event handlers (i.e.
no concurrent invocation). Use of strands allows execution of code in a
multithreaded program without the need for explicit locking (e.g. using
mutexes).
Strands may be either implicit or explicit, as illustrated by the following
alternative approaches:
* Calling io_context::run() from only one thread means all event handlers
execute in an implicit strand, due to the io_context's guarantee that handlers
are only invoked from inside run().
* Where there is a single chain of asynchronous operations associated with a
connection (e.g. in a half duplex protocol implementation like HTTP) there is
no possibility of concurrent execution of the handlers. This is an implicit
strand.
* An explicit strand is an instance of `strand<>` or `io_context::strand`. All
event handler function objects need to be bound to the strand using
`boost::asio::bind_executor()` or otherwise posted/dispatched through the strand
object.
In the case of composed asynchronous operations, such as `async_read()` or
`async_read_until()`, if a completion handler goes through a strand, then all
intermediate handlers should also go through the same strand. This is needed to
ensure thread safe access for any objects that are shared between the caller
and the composed operation (in the case of `async_read()` it's the socket,
which the caller can `close()` to cancel the operation).
To achieve this, all asynchronous operations obtain the handler's associated
executor by using the `get_associated_executor` function. For example:
boost::asio::associated_executor_t<Handler> a = boost::asio::get_associated_executor(h);
The associated executor must satisfy the Executor requirements. It will be used
by the asynchronous operation to submit both intermediate and final handlers
for execution.
The executor may be customised for a particular handler type by specifying a
nested type `executor_type` and member function `get_executor()`:
class my_handler
{
public:
// Custom implementation of Executor type requirements.
typedef my_executor executor_type;
// Return a custom executor implementation.
executor_type get_executor() const noexcept
{
return my_executor();
}
void operator()() { ... }
};
In more complex cases, the `associated_executor` template may be partially
specialised directly:
struct my_handler
{
void operator()() { ... }
};
namespace boost { namespace asio {
template <class Executor>
struct associated_executor<my_handler, Executor>
{
// Custom implementation of Executor type requirements.
typedef my_executor type;
// Return a custom executor implementation.
static type get(const my_handler&,
const Executor& = Executor()) noexcept
{
return my_executor();
}
};
} } // namespace boost::asio
The `boost::asio::bind_executor()` function is a helper to bind a specific executor
object, such as a strand, to a completion handler. This binding automatically
associates an executor as shown above. For example, to bind a strand to a
completion handler we would simply write:
my_socket.async_read_some(my_buffer,
boost::asio::bind_executor(my_strand,
[](error_code ec, size_t length)
{
// ...
}));
[heading See Also]
[link boost_asio.reference.associated_executor associated_executor],
[link boost_asio.reference.get_associated_executor get_associated_executor],
[link boost_asio.reference.bind_executor bind_executor],
[link boost_asio.reference.strand strand],
[link boost_asio.reference.io_context__strand io_context::strand],
[link boost_asio.tutorial.tuttimer5 tutorial Timer.5],
[link boost_asio.examples.cpp03_examples.http_server_3 HTTP server 3 example].
[endsect]

View File

@@ -0,0 +1,62 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:streams Streams, Short Reads and Short Writes]
Many I/O objects in Boost.Asio are stream-oriented. This means that:
* There are no message boundaries. The data being transferred is a continuous
sequence of bytes.
* Read or write operations may transfer fewer bytes than requested. This is
referred to as a short read or short write.
Objects that provide stream-oriented I/O model one or more of the following
type requirements:
* `SyncReadStream`, where synchronous read operations are performed using a
member function called `read_some()`.
* `AsyncReadStream`, where asynchronous read operations are performed using a
member function called `async_read_some()`.
* `SyncWriteStream`, where synchronous write operations are performed using a
member function called `write_some()`.
* `AsyncWriteStream`, where asynchronous write operations are performed using a
member function called `async_write_some()`.
Examples of stream-oriented I/O objects include `ip::tcp::socket`,
`ssl::stream<>`, `posix::stream_descriptor`, `windows::stream_handle`, etc.
Programs typically want to transfer an exact number of bytes. When a short read
or short write occurs the program must restart the operation, and continue to
do so until the required number of bytes has been transferred. Boost.Asio provides
generic functions that do this automatically: `read()`, `async_read()`,
`write()` and `async_write()`.
[heading Why EOF is an Error]
* The end of a stream can cause `read`, `async_read`, `read_until` or
`async_read_until` functions to violate their contract. E.g.
a read of N bytes may finish early due to EOF.
* An EOF error may be used to distinguish the end of a stream from a successful
read of size 0.
[heading See Also]
[link boost_asio.reference.async_read async_read()],
[link boost_asio.reference.async_write async_write()],
[link boost_asio.reference.read read()],
[link boost_asio.reference.write write()],
[link boost_asio.reference.AsyncReadStream AsyncReadStream],
[link boost_asio.reference.AsyncWriteStream AsyncWriteStream],
[link boost_asio.reference.SyncReadStream SyncReadStream],
[link boost_asio.reference.SyncWriteStream SyncWriteStream].
[endsect]

View File

@@ -0,0 +1,67 @@
digraph g
{
graph
[
nodesep="0.6"
];
edge
[
fontname="Helvetica",
fontsize=10,
labelfontname="Helvetica",
labelfontsize=10
];
node
[
fontname="Helvetica",
fontsize=10,
shape=box
];
edge
[
arrowhead="open"
]
// Program elements.
{
operating_system [ label="Operating System", shape=ellipse ];
io_context [ label="I/O Execution Context\ne.g. io_context" ];
io_object [ label="I/O Object\ne.g. socket" ];
your_program [ label="Your Program" ];
}
// Owning relationships.
{
edge [ arrowtail="diamond" ];
your_program:w -> io_object:nw;
your_program:se -> io_context:ne;
}
// Non-owning relationships;
{
io_object:sw -> io_context:w;
}
// Actions.
{
edge [ style="dashed", color="#808080" ];
// Forward actions.
{
your_program:sw -> io_object:n [ label="1" ];
io_object:s -> io_context:nw [ label="2" ];
io_context:sw -> operating_system:nw [ label="3" ];
}
// Reverse actions.
{
edge [ arrowhead="none", arrowtail="open" ];
io_context:se -> operating_system:ne [ label="4" ];
io_object:se -> io_context:n [ label="5" ];
your_program:s -> io_object:ne [ label="6" ];
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,67 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:threads Threads and Boost.Asio]
[heading Thread Safety]
In general, it is safe to make concurrent use of distinct objects, but unsafe
to make concurrent use of a single object. However, types such as `io_context`
provide a stronger guarantee that it is safe to use a single object
concurrently.
[heading Thread Pools]
Multiple threads may call `io_context::run()` to set up a pool of threads from
which completion handlers may be invoked. This approach may also be used with
`post()` as a means to perform arbitrary computational tasks across a thread
pool.
Note that all threads that have joined an `io_context`'s pool are considered
equivalent, and the `io_context` may distribute work across them in an
arbitrary fashion.
[heading Internal Threads]
The implementation of this library for a particular platform may make use of
one or more internal threads to emulate asynchronicity. As far as possible,
these threads must be invisible to the library user. In particular, the threads:
* must not call the user's code directly; and
* must block all signals.
This approach is complemented by the following guarantee:
* Asynchronous completion handlers will only be called from threads that are
currently calling `io_context::run()`.
Consequently, it is the library user's responsibility to create and manage all
threads to which the notifications will be delivered.
The reasons for this approach include:
* By only calling `io_context::run()` from a single thread, the user's code can
avoid the development complexity associated with synchronisation. For
example, a library user can implement scalable servers that are
single-threaded (from the user's point of view).
* A library user may need to perform initialisation in a thread shortly after
the thread starts and before any other application code is executed. For
example, users of Microsoft's COM must call `CoInitializeEx` before any other
COM operations can be called from that thread.
* The library interface is decoupled from interfaces for thread creation and
management, and permits implementations on platforms where threads are not
available.
[heading See Also]
[link boost_asio.reference.io_context io_context],
[link boost_asio.reference.post post].
[endsect]

View File

@@ -0,0 +1,52 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:timers Timers]
Long running I/O operations will often have a deadline by which they must have
completed. These deadlines may be expressed as absolute times, but are often
calculated relative to the current time.
As a simple example, to perform a synchronous wait operation on a timer using a
relative time one may write:
io_context i;
...
deadline_timer t(i);
t.expires_from_now(boost::posix_time::seconds(5));
t.wait();
More commonly, a program will perform an asynchronous wait operation on a
timer:
void handler(boost::system::error_code ec) { ... }
...
io_context i;
...
deadline_timer t(i);
t.expires_from_now(boost::posix_time::milliseconds(400));
t.async_wait(handler);
...
i.run();
The deadline associated with a timer may also be obtained as a relative time:
boost::posix_time::time_duration time_until_expiry
= t.expires_from_now();
or as an absolute time to allow composition of timers:
deadline_timer t2(i);
t2.expires_at(t.expires_at() + boost::posix_time::seconds(30));
[heading See Also]
[link boost_asio.reference.basic_deadline_timer basic_deadline_timer],
[link boost_asio.reference.deadline_timer deadline_timer],
[link boost_asio.tutorial.tuttimer1 timer tutorials].
[endsect]

View File

@@ -0,0 +1,126 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:windows Windows-Specific Functionality]
[link boost_asio.overview.windows.stream_handle Stream-Oriented HANDLEs]
[link boost_asio.overview.windows.random_access_handle Random-Access HANDLEs]
[link boost_asio.overview.windows.object_handle Object HANDLEs]
[section:stream_handle Stream-Oriented HANDLEs]
Boost.Asio contains classes to allow asynchronous read and write operations to be
performed on Windows `HANDLE`s, such as named pipes.
For example, to perform asynchronous operations on a named pipe, the following
object may be created:
HANDLE handle = ::CreateFile(...);
windows::stream_handle pipe(my_io_context, handle);
These are then used as synchronous or asynchronous read and write streams. This
means the objects can be used with any of the [link boost_asio.reference.read
read()], [link boost_asio.reference.async_read async_read()], [link
boost_asio.reference.write write()], [link boost_asio.reference.async_write
async_write()], [link boost_asio.reference.read_until read_until()] or [link
boost_asio.reference.async_read_until async_read_until()] free functions.
The kernel object referred to by the `HANDLE` must support use with I/O
completion ports (which means that named pipes are supported, but anonymous
pipes and console streams are not).
[heading See Also]
[link boost_asio.reference.windows__stream_handle windows::stream_handle].
[heading Notes]
Windows stream `HANDLE`s are only available at compile time when targeting
Windows and only when the I/O completion port backend is used (which is the
default). A program may test for the macro `BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE` to
determine whether they are supported.
[endsect]
[/-----------------------------------------------------------------------------]
[section:random_access_handle Random-Access HANDLEs]
Boost.Asio provides Windows-specific classes that permit asynchronous read and write
operations to be performed on HANDLEs that refer to regular files.
For example, to perform asynchronous operations on a file the following object
may be created:
HANDLE handle = ::CreateFile(...);
windows::random_access_handle file(my_io_context, handle);
Data may be read from or written to the handle using one of the
`read_some_at()`, `async_read_some_at()`, `write_some_at()` or
`async_write_some_at()` member functions. However, like the equivalent
functions (`read_some()`, etc.) on streams, these functions are only required
to transfer one or more bytes in a single operation. Therefore free functions
called [link boost_asio.reference.read_at read_at()], [link
boost_asio.reference.async_read_at async_read_at()], [link boost_asio.reference.write_at
write_at()] and [link boost_asio.reference.async_write_at async_write_at()] have been
created to repeatedly call the corresponding [^[**]_some_at()] function until
all data has been transferred.
[heading See Also]
[link boost_asio.reference.windows__random_access_handle windows::random_access_handle].
[heading Notes]
Windows random-access `HANDLE`s are only available at compile time when
targeting Windows and only when the I/O completion port backend is used (which
is the default). A program may test for the macro
`BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE` to determine whether they are
supported.
[endsect]
[/-----------------------------------------------------------------------------]
[section:object_handle Object HANDLEs]
Boost.Asio provides Windows-specific classes that permit asynchronous wait operations
to be performed on HANDLEs to kernel objects of the following types:
* Change notification
* Console input
* Event
* Memory resource notification
* Process
* Semaphore
* Thread
* Waitable timer
For example, to perform asynchronous operations on an event, the following
object may be created:
HANDLE handle = ::CreateEvent(...);
windows::object_handle file(my_io_context, handle);
The `wait()` and `async_wait()` member functions may then be used to wait until
the kernel object is signalled.
[heading See Also]
[link boost_asio.reference.windows__object_handle windows::object_handle].
[heading Notes]
Windows object `HANDLE`s are only available at compile time when targeting
Windows. Programs may test for the macro `BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE` to
determine whether they are supported.
[endsect]
[endsect]

View File

@@ -0,0 +1,88 @@
#!/usr/bin/perl -w
# Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
use strict;
open(my $fh, "<../include/boost/asio/detail/config.hpp") or die("can't open config.hpp");
my $current_comment = "";
my %has_macros = ();
my %disable_macros = ();
while (my $line = <$fh>)
{
chomp($line);
if ($line =~ /^$/)
{
$current_comment = "";
}
elsif ($line =~ /^\/\/ (.*)$/)
{
$current_comment = $current_comment . $1 . "\n";
}
elsif ($line =~ /^# *define *BOOST_ASIO_HAS_([A-Z-0-9_]*) 1/)
{
if (not defined($has_macros{$1}))
{
$has_macros{$1} = $current_comment;
}
}
elsif ($line =~ /BOOST_ASIO_DISABLE_([A-Z-0-9_]*)/)
{
$disable_macros{$1} = 1;
}
}
my $intro = <<EOF;
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[heading Compiler/platform feature detection macros]
Asio automatically defines preprocessor macros corresponding to the detected
available features on a particular compiler and target platform. These macros
are named with the prefix `BOOST_ASIO_HAS_`, and are listed in the table below.
Many of these macros also have a corresponding `BOOST_ASIO_DISABLE_` macro that
may be used to explicitly disable the feature.
In general, `BOOST_ASIO_HAS_` macros should not be explicitly defined by the
user, except when absolutely required as a workaround for the latest version of
a compiler or platform. For older compiler/platform combinations where a
specific `BOOST_ASIO_HAS_` macro is not automatically defined, testing may have
shown that a claimed feature isn't sufficiently conformant to be compatible
with Boost.Asio's needs.
EOF
print("$intro\n");
print("[table\n");
print(" [[Macro][Description][Macro to disable feature]]\n");
for my $macro (sort keys %has_macros)
{
print(" [\n");
print(" [`BOOST_ASIO_HAS_$macro`]\n");
print(" [\n");
my $description = $has_macros{$macro};
chomp($description);
$description =~ s/\n/\n /g;
print(" $description\n");
print(" ]\n");
if (defined $disable_macros{$macro})
{
print(" [`BOOST_ASIO_DISABLE_$macro`]\n");
}
else
{
print(" []\n");
}
print(" ]\n");
}
print("]\n");

View File

@@ -0,0 +1,620 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[heading Compiler/platform feature detection macros]
Asio automatically defines preprocessor macros corresponding to the detected
available features on a particular compiler and target platform. These macros
are named with the prefix `BOOST_ASIO_HAS_`, and are listed in the table below.
Many of these macros also have a corresponding `BOOST_ASIO_DISABLE_` macro that
may be used to explicitly disable the feature.
In general, `BOOST_ASIO_HAS_` macros should not be explicitly defined by the
user, except when absolutely required as a workaround for the latest version of
a compiler or platform. For older compiler/platform combinations where a
specific `BOOST_ASIO_HAS_` macro is not automatically defined, testing may have
shown that a claimed feature isn't sufficiently conformant to be compatible
with Boost.Asio's needs.
[table
[[Macro][Description][Macro to disable feature]]
[
[`BOOST_ASIO_HAS_ALIAS_TEMPLATES`]
[
Support alias templates on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_ALIAS_TEMPLATES`]
]
[
[`BOOST_ASIO_HAS_ALIGNED_NEW`]
[
Support for operator new with alignment argument.
]
[`BOOST_ASIO_DISABLE_ALIGNED_NEW`]
]
[
[`BOOST_ASIO_HAS_ALIGNOF`]
[
Support for the alignof operator.
]
[`BOOST_ASIO_DISABLE_ALIGNOF`]
]
[
[`BOOST_ASIO_HAS_BOOST_ALIGN`]
[
Boost align library.
]
[`BOOST_ASIO_DISABLE_BOOST_ALIGN`]
]
[
[`BOOST_ASIO_HAS_BOOST_ARRAY`]
[
Boost array library.
]
[`BOOST_ASIO_DISABLE_BOOST_ARRAY`]
]
[
[`BOOST_ASIO_HAS_BOOST_ASSERT`]
[
Boost assert macro.
]
[`BOOST_ASIO_DISABLE_BOOST_ASSERT`]
]
[
[`BOOST_ASIO_HAS_BOOST_BIND`]
[
Boost bind function.
]
[`BOOST_ASIO_DISABLE_BOOST_BIND`]
]
[
[`BOOST_ASIO_HAS_BOOST_CHRONO`]
[
Boost support for chrono.
]
[`BOOST_ASIO_DISABLE_BOOST_CHRONO`]
]
[
[`BOOST_ASIO_HAS_BOOST_CONFIG`]
[
]
[]
]
[
[`BOOST_ASIO_HAS_BOOST_DATE_TIME`]
[
Boost support for the DateTime library.
]
[`BOOST_ASIO_DISABLE_BOOST_DATE_TIME`]
]
[
[`BOOST_ASIO_HAS_BOOST_LIMITS`]
[
Boost limits header.
]
[`BOOST_ASIO_DISABLE_BOOST_LIMITS`]
]
[
[`BOOST_ASIO_HAS_BOOST_REGEX`]
[
Boost regex library.
]
[`BOOST_ASIO_DISABLE_BOOST_REGEX`]
]
[
[`BOOST_ASIO_HAS_BOOST_THROW_EXCEPTION`]
[
Boost throw_exception function.
]
[`BOOST_ASIO_DISABLE_BOOST_THROW_EXCEPTION`]
]
[
[`BOOST_ASIO_HAS_BOOST_WORKAROUND`]
[
Boost's BOOST_WORKAROUND macro.
]
[`BOOST_ASIO_DISABLE_BOOST_WORKAROUND`]
]
[
[`BOOST_ASIO_HAS_CHRONO`]
[
Some form of chrono library is available.
]
[]
]
[
[`BOOST_ASIO_HAS_CLANG_LIBCXX`]
[
Clang / libc++ detection.
]
[]
]
[
[`BOOST_ASIO_HAS_CONCEPTS`]
[
Support concepts on compilers known to allow them.
]
[`BOOST_ASIO_DISABLE_CONCEPTS`]
]
[
[`BOOST_ASIO_HAS_CONSTANT_EXPRESSION_SFINAE`]
[
Support SFINAE use of constant expressions on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_CONSTANT_EXPRESSION_SFINAE`]
]
[
[`BOOST_ASIO_HAS_CONSTEXPR`]
[
Support constexpr on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_CONSTEXPR`]
]
[
[`BOOST_ASIO_HAS_CO_AWAIT`]
[
Support the co_await keyword on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_CO_AWAIT`]
]
[
[`BOOST_ASIO_HAS_CSTDINT`]
[
Standard library support for the cstdint header.
]
[`BOOST_ASIO_DISABLE_CSTDINT`]
]
[
[`BOOST_ASIO_HAS_CXX11_ALLOCATORS`]
[
Standard library support for the C++11 allocator additions.
]
[`BOOST_ASIO_DISABLE_CXX11_ALLOCATORS`]
]
[
[`BOOST_ASIO_HAS_DECLTYPE`]
[
Support automatic type deduction on compilers known to support it.
]
[`BOOST_ASIO_DISABLE_DECLTYPE`]
]
[
[`BOOST_ASIO_HAS_DEFAULT_FUNCTION_TEMPLATE_ARGUMENTS`]
[
Support default function template arguments on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_DEFAULT_FUNCTION_TEMPLATE_ARGUMENTS`]
]
[
[`BOOST_ASIO_HAS_DEV_POLL`]
[
Solaris: /dev/poll.
]
[`BOOST_ASIO_DISABLE_DEV_POLL`]
]
[
[`BOOST_ASIO_HAS_EPOLL`]
[
Linux: epoll, eventfd and timerfd.
]
[`BOOST_ASIO_DISABLE_EPOLL`]
]
[
[`BOOST_ASIO_HAS_EVENTFD`]
[
Linux: epoll, eventfd and timerfd.
]
[`BOOST_ASIO_DISABLE_EVENTFD`]
]
[
[`BOOST_ASIO_HAS_GETADDRINFO`]
[
Can use getaddrinfo() and getnameinfo().
]
[`BOOST_ASIO_DISABLE_GETADDRINFO`]
]
[
[`BOOST_ASIO_HAS_HANDLER_HOOKS`]
[
Handler hooking. Disabled for ancient Borland C++ and gcc compilers.
]
[`BOOST_ASIO_DISABLE_HANDLER_HOOKS`]
]
[
[`BOOST_ASIO_HAS_IOCP`]
[
Windows: IO Completion Ports.
]
[`BOOST_ASIO_DISABLE_IOCP`]
]
[
[`BOOST_ASIO_HAS_KQUEUE`]
[
Mac OS X, FreeBSD, NetBSD, OpenBSD: kqueue.
]
[`BOOST_ASIO_DISABLE_KQUEUE`]
]
[
[`BOOST_ASIO_HAS_LOCAL_SOCKETS`]
[
UNIX domain sockets.
]
[`BOOST_ASIO_DISABLE_LOCAL_SOCKETS`]
]
[
[`BOOST_ASIO_HAS_MOVE`]
[
Support move construction and assignment on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_MOVE`]
]
[
[`BOOST_ASIO_HAS_MSG_NOSIGNAL`]
[
Kernel support for MSG_NOSIGNAL.
]
[]
]
[
[`BOOST_ASIO_HAS_NOEXCEPT`]
[
Support noexcept on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_NOEXCEPT`]
]
[
[`BOOST_ASIO_HAS_NULLPTR`]
[
Standard library support for the nullptr_t type.
]
[`BOOST_ASIO_DISABLE_NULLPTR`]
]
[
[`BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR`]
[
POSIX: stream-oriented file descriptors.
]
[`BOOST_ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR`]
]
[
[`BOOST_ASIO_HAS_PTHREADS`]
[
POSIX threads.
]
[]
]
[
[`BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS`]
[
Support ref-qualified functions on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_REF_QUALIFIED_FUNCTIONS`]
]
[
[`BOOST_ASIO_HAS_RETURN_TYPE_DEDUCTION`]
[
Support return type deduction on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_RETURN_TYPE_DEDUCTION`]
]
[
[`BOOST_ASIO_HAS_SECURE_RTL`]
[
Microsoft Visual C++'s secure C runtime library.
]
[`BOOST_ASIO_DISABLE_SECURE_RTL`]
]
[
[`BOOST_ASIO_HAS_SERIAL_PORT`]
[
Serial ports.
]
[`BOOST_ASIO_DISABLE_SERIAL_PORT`]
]
[
[`BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES`]
[
Support SFINAEd template variables on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_SFINAE_VARIABLE_TEMPLATES`]
]
[
[`BOOST_ASIO_HAS_SIGACTION`]
[
Can use sigaction() instead of signal().
]
[`BOOST_ASIO_DISABLE_SIGACTION`]
]
[
[`BOOST_ASIO_HAS_SIGNAL`]
[
Can use signal().
]
[`BOOST_ASIO_DISABLE_SIGNAL`]
]
[
[`BOOST_ASIO_HAS_SOURCE_LOCATION`]
[
Standard library has a source_location that we can use.
]
[`BOOST_ASIO_DISABLE_SOURCE_LOCATION`]
]
[
[`BOOST_ASIO_HAS_SSIZE_T`]
[
Support for POSIX ssize_t typedef.
]
[`BOOST_ASIO_DISABLE_SSIZE_T`]
]
[
[`BOOST_ASIO_HAS_STD_ADDRESSOF`]
[
Standard library support for addressof.
]
[`BOOST_ASIO_DISABLE_STD_ADDRESSOF`]
]
[
[`BOOST_ASIO_HAS_STD_ALLOCATOR_ARG`]
[
Standard library support for allocator_arg_t.
]
[`BOOST_ASIO_DISABLE_STD_ALLOCATOR_ARG`]
]
[
[`BOOST_ASIO_HAS_STD_ANY`]
[
Standard library support for std::any.
]
[`BOOST_ASIO_DISABLE_STD_ANY`]
]
[
[`BOOST_ASIO_HAS_STD_ARRAY`]
[
Standard library support for arrays.
]
[`BOOST_ASIO_DISABLE_STD_ARRAY`]
]
[
[`BOOST_ASIO_HAS_STD_ATOMIC`]
[
Standard library support for atomic operations.
]
[`BOOST_ASIO_DISABLE_STD_ATOMIC`]
]
[
[`BOOST_ASIO_HAS_STD_CALL_ONCE`]
[
Standard library support for the call_once function.
]
[`BOOST_ASIO_DISABLE_STD_CALL_ONCE`]
]
[
[`BOOST_ASIO_HAS_STD_CHRONO`]
[
Standard library support for chrono. Some standard libraries (such as the
libstdc++ shipped with gcc 4.6) provide monotonic_clock as per early C++0x
drafts, rather than the eventually standardised name of steady_clock.
]
[`BOOST_ASIO_DISABLE_STD_CHRONO`]
]
[
[`BOOST_ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK`]
[
Standard library support for chrono. Some standard libraries (such as the
libstdc++ shipped with gcc 4.6) provide monotonic_clock as per early C++0x
drafts, rather than the eventually standardised name of steady_clock.
]
[]
]
[
[`BOOST_ASIO_HAS_STD_COROUTINE`]
[
Standard library support for coroutines.
]
[`BOOST_ASIO_DISABLE_STD_COROUTINE`]
]
[
[`BOOST_ASIO_HAS_STD_EXCEPTION_PTR`]
[
Standard library support for std::exception_ptr and std::current_exception.
]
[`BOOST_ASIO_DISABLE_STD_EXCEPTION_PTR`]
]
[
[`BOOST_ASIO_HAS_STD_EXPERIMENTAL_SOURCE_LOCATION`]
[
Standard library support for std::experimental::source_location.
]
[`BOOST_ASIO_DISABLE_STD_EXPERIMENTAL_SOURCE_LOCATION`]
]
[
[`BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW`]
[
Standard library support for std::experimental::string_view.
]
[`BOOST_ASIO_DISABLE_STD_EXPERIMENTAL_STRING_VIEW`]
]
[
[`BOOST_ASIO_HAS_STD_FUNCTION`]
[
Standard library support for the function class.
]
[`BOOST_ASIO_DISABLE_STD_FUNCTION`]
]
[
[`BOOST_ASIO_HAS_STD_FUTURE`]
[
Standard library support for futures.
]
[`BOOST_ASIO_DISABLE_STD_FUTURE`]
]
[
[`BOOST_ASIO_HAS_STD_HASH`]
[
Standard library support for std::hash.
]
[`BOOST_ASIO_DISABLE_STD_HASH`]
]
[
[`BOOST_ASIO_HAS_STD_INVOKE_RESULT`]
[
Standard library has invoke_result (which supersedes result_of).
]
[`BOOST_ASIO_DISABLE_STD_INVOKE_RESULT`]
]
[
[`BOOST_ASIO_HAS_STD_IOSTREAM_MOVE`]
[
Standard library support for iostream move construction and assignment.
]
[`BOOST_ASIO_DISABLE_STD_IOSTREAM_MOVE`]
]
[
[`BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR`]
[
Standard library support for the mutex and condition variable classes.
]
[`BOOST_ASIO_DISABLE_STD_MUTEX_AND_CONDVAR`]
]
[
[`BOOST_ASIO_HAS_STD_NESTED_EXCEPTION`]
[
Standard library support for std::nested_exception.
]
[`BOOST_ASIO_DISABLE_STD_NESTED_EXCEPTION`]
]
[
[`BOOST_ASIO_HAS_STD_REFERENCE_WRAPPER`]
[
Standard library support for the reference_wrapper class.
]
[`BOOST_ASIO_DISABLE_STD_REFERENCE_WRAPPER`]
]
[
[`BOOST_ASIO_HAS_STD_SHARED_PTR`]
[
Standard library support for shared_ptr and weak_ptr.
]
[`BOOST_ASIO_DISABLE_STD_SHARED_PTR`]
]
[
[`BOOST_ASIO_HAS_STD_STRING_VIEW`]
[
Standard library support for std::string_view.
]
[`BOOST_ASIO_DISABLE_STD_STRING_VIEW`]
]
[
[`BOOST_ASIO_HAS_STD_SYSTEM_ERROR`]
[
Standard library support for system errors.
]
[`BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR`]
]
[
[`BOOST_ASIO_HAS_STD_THREAD`]
[
Standard library support for the thread class.
]
[`BOOST_ASIO_DISABLE_STD_THREAD`]
]
[
[`BOOST_ASIO_HAS_STD_TYPE_TRAITS`]
[
Standard library support for type traits.
]
[`BOOST_ASIO_DISABLE_STD_TYPE_TRAITS`]
]
[
[`BOOST_ASIO_HAS_STRING_VIEW`]
[
Standard library has a string_view that we can use.
]
[`BOOST_ASIO_DISABLE_STRING_VIEW`]
]
[
[`BOOST_ASIO_HAS_THREADS`]
[
Threads.
]
[`BOOST_ASIO_DISABLE_THREADS`]
]
[
[`BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION`]
[
Support for the __thread keyword extension.
]
[`BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION`]
]
[
[`BOOST_ASIO_HAS_TIMERFD`]
[
Linux: epoll, eventfd and timerfd.
]
[]
]
[
[`BOOST_ASIO_HAS_UNISTD_H`]
[
On POSIX (and POSIX-like) platforms we need to include unistd.h in order to
get access to the various platform feature macros, e.g. to be able to test
for threads support.
]
[]
]
[
[`BOOST_ASIO_HAS_VARIABLE_TEMPLATES`]
[
Support template variables on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_VARIABLE_TEMPLATES`]
]
[
[`BOOST_ASIO_HAS_VARIADIC_TEMPLATES`]
[
Support variadic templates on compilers known to allow it.
]
[`BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES`]
]
[
[`BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE`]
[
Windows: object handles.
]
[`BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE`]
]
[
[`BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR`]
[
Windows: OVERLAPPED wrapper.
]
[`BOOST_ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR`]
]
[
[`BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE`]
[
Windows: random access handles.
]
[`BOOST_ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE`]
]
[
[`BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE`]
[
Windows: stream handles.
]
[`BOOST_ASIO_DISABLE_WINDOWS_STREAM_HANDLE`]
]
[
[`BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE`]
[
Enable workarounds for lack of working expression SFINAE.
]
[`BOOST_ASIO_DISABLE_WORKING_EXPRESSION_SFINAE`]
]
]

View File

@@ -0,0 +1,811 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "../../../tools/boostbook/dtd/boostbook.dtd">
<!--
Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
-->
<informaltable frame="all">
<tgroup cols="4">
<colspec colname="a"/>
<colspec colname="b"/>
<colspec colname="c"/>
<colspec colname="d"/>
<thead>
<row>
<entry valign="center" namest="a" nameend="a">
<bridgehead renderas="sect2">Properties</bridgehead>
</entry>
<entry valign="center" namest="b" nameend="d">
<bridgehead renderas="sect2">Execution</bridgehead>
</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top">
<bridgehead renderas="sect3">Customisation Points</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.prefer">prefer</link></member>
<member><link linkend="boost_asio.reference.query">query</link></member>
<member><link linkend="boost_asio.reference.require">require</link></member>
<member><link linkend="boost_asio.reference.require_concept">require_concept</link></member>
</simplelist>
<bridgehead renderas="sect3">Traits</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.can_prefer">can_prefer</link></member>
<member><link linkend="boost_asio.reference.can_query">can_query</link></member>
<member><link linkend="boost_asio.reference.can_require">can_require</link></member>
<member><link linkend="boost_asio.reference.can_require_concept">can_require_concept</link></member>
<member><link linkend="boost_asio.reference.is_nothrow_prefer">is_nothrow_prefer</link></member>
<member><link linkend="boost_asio.reference.is_nothrow_query">is_nothrow_query</link></member>
<member><link linkend="boost_asio.reference.is_nothrow_require">is_nothrow_require</link></member>
<member><link linkend="boost_asio.reference.is_nothrow_require_concept">is_nothrow_require_concept</link></member>
<member><link linkend="boost_asio.reference.prefer_result">prefer_result</link></member>
<member><link linkend="boost_asio.reference.query_result">query_result</link></member>
<member><link linkend="boost_asio.reference.require_result">require_result</link></member>
<member><link linkend="boost_asio.reference.require_concept_result">require_concept_result</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.execution__any_executor">execution::any_executor</link></member>
</simplelist>
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.execution__bad_executor">execution::bad_executor</link></member>
<member><link linkend="boost_asio.reference.execution__invocable_archetype">execution::invocable_archetype</link></member>
<member><link linkend="boost_asio.reference.execution__receiver_invocation_error">execution::receiver_invocation_error</link></member>
</simplelist>
<bridgehead renderas="sect3">Properties</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.execution__allocator_t">execution::allocator_t</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_t">execution::blocking_t</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_t__possibly_t">execution::blocking_t::possibly_t</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_t__always_t">execution::blocking_t::always_t</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_t__never_t">execution::blocking_t::never_t</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_adaptation_t">execution::blocking_adaptation_t</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_adaptation_t__disallowed_t">execution::blocking_adaptation_t::disallowed_t</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_adaptation_t__allowed_t">execution::blocking_adaptation_t::allowed_t</link></member>
<member><link linkend="boost_asio.reference.execution__bulk_guarantee_t">execution::bulk_guarantee_t</link></member>
<member><link linkend="boost_asio.reference.execution__bulk_guarantee_t__unsequenced_t">execution::bulk_guarantee_t::unsequenced_t</link></member>
<member><link linkend="boost_asio.reference.execution__bulk_guarantee_t__sequenced_t">execution::bulk_guarantee_t::sequenced_t</link></member>
<member><link linkend="boost_asio.reference.execution__bulk_guarantee_t__parallel_t">execution::bulk_guarantee_t::parallel_t</link></member>
<member><link linkend="boost_asio.reference.execution__context_t">execution::context_t</link></member>
<member><link linkend="boost_asio.reference.execution__context_as_t">execution::context_as_t</link></member>
<member><link linkend="boost_asio.reference.execution__mapping_t">execution::mapping_t</link></member>
<member><link linkend="boost_asio.reference.execution__mapping_t__thread_t">execution::mapping_t::thread_t</link></member>
<member><link linkend="boost_asio.reference.execution__mapping_t__new_thread_t">execution::mapping_t::new_thread_t</link></member>
<member><link linkend="boost_asio.reference.execution__mapping_t__other_t">execution::mapping_t::other_t</link></member>
<member><link linkend="boost_asio.reference.execution__occupancy_t">execution::occupancy_t</link></member>
<member><link linkend="boost_asio.reference.execution__outstanding_work_t">execution::outstanding_work_t</link></member>
<member><link linkend="boost_asio.reference.execution__outstanding_work_t__untracked_t">execution::outstanding_work_t::untracked_t</link></member>
<member><link linkend="boost_asio.reference.execution__outstanding_work_t__tracked_t">execution::outstanding_work_t::tracked_t</link></member>
<member><link linkend="boost_asio.reference.execution__prefer_only">execution::prefer_only</link></member>
<member><link linkend="boost_asio.reference.execution__relationship_t">execution::relationship_t</link></member>
<member><link linkend="boost_asio.reference.execution__relationship_t__fork_t">execution::relationship_t::fork_t</link></member>
<member><link linkend="boost_asio.reference.execution__relationship_t__continuation_t">execution::relationship_t::continuation_t</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Customisation Points</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.execution__bulk_execute">execution::bulk_execute</link></member>
<member><link linkend="boost_asio.reference.execution__connect">execution::connect</link></member>
<member><link linkend="boost_asio.reference.execution__execute">execution::execute</link></member>
<member><link linkend="boost_asio.reference.execution__schedule">execution::schedule</link></member>
<member><link linkend="boost_asio.reference.execution__set_done">execution::set_done</link></member>
<member><link linkend="boost_asio.reference.execution__set_error">execution::set_error</link></member>
<member><link linkend="boost_asio.reference.execution__set_value">execution::set_value</link></member>
<member><link linkend="boost_asio.reference.execution__start">execution::start</link></member>
<member><link linkend="boost_asio.reference.execution__submit">execution::submit</link></member>
</simplelist>
<bridgehead renderas="sect3">Property Objects</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.execution__allocator">execution::allocator</link></member>
<member><link linkend="boost_asio.reference.execution__blocking">execution::blocking</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_t.possibly">execution::blocking.possibly</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_t.always">execution::blocking.always</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_t.never">execution::blocking.never</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_adaptation">execution::blocking_adaptation</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_adaptation_t.disallowed">execution::blocking_adaptation.disallowed</link></member>
<member><link linkend="boost_asio.reference.execution__blocking_adaptation_t.allowed">execution::blocking_adaptation.allowed</link></member>
<member><link linkend="boost_asio.reference.execution__bulk_guarantee">execution::bulk_guarantee</link></member>
<member><link linkend="boost_asio.reference.execution__bulk_guarantee_t.unsequenced">execution::bulk_guarantee.unsequenced</link></member>
<member><link linkend="boost_asio.reference.execution__bulk_guarantee_t.sequenced">execution::bulk_guarantee.sequenced</link></member>
<member><link linkend="boost_asio.reference.execution__bulk_guarantee_t.parallel">execution::bulk_guarantee.parallel</link></member>
<member><link linkend="boost_asio.reference.execution__context">execution::context</link></member>
<member><link linkend="boost_asio.reference.execution__context_as">execution::context_as</link></member>
<member><link linkend="boost_asio.reference.execution__mapping">execution::mapping</link></member>
<member><link linkend="boost_asio.reference.execution__mapping_t.thread">execution::mapping.thread</link></member>
<member><link linkend="boost_asio.reference.execution__mapping_t.new_thread">execution::mapping.new_thread</link></member>
<member><link linkend="boost_asio.reference.execution__mapping_t.other">execution::mapping.other</link></member>
<member><link linkend="boost_asio.reference.execution__occupancy">execution::occupancy</link></member>
<member><link linkend="boost_asio.reference.execution__outstanding_work">execution::outstanding_work</link></member>
<member><link linkend="boost_asio.reference.execution__outstanding_work_t.untracked">execution::outstanding_work.untracked</link></member>
<member><link linkend="boost_asio.reference.execution__outstanding_work_t.tracked">execution::outstanding_work.tracked</link></member>
<member><link linkend="boost_asio.reference.execution__relationship">execution::relationship</link></member>
<member><link linkend="boost_asio.reference.execution__relationship_t.fork">execution::relationship.fork</link></member>
<member><link linkend="boost_asio.reference.execution__relationship_t.continuation">execution::relationship.continuation</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Type Traits</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.execution__can_bulk_execute">execution::can_bulk_execute</link></member>
<member><link linkend="boost_asio.reference.execution__can_connect">execution::can_connect</link></member>
<member><link linkend="boost_asio.reference.execution__can_execute">execution::can_execute</link></member>
<member><link linkend="boost_asio.reference.execution__can_schedule">execution::can_schedule</link></member>
<member><link linkend="boost_asio.reference.execution__can_set_done">execution::can_set_done</link></member>
<member><link linkend="boost_asio.reference.execution__can_set_error">execution::can_set_error</link></member>
<member><link linkend="boost_asio.reference.execution__can_set_value">execution::can_set_value</link></member>
<member><link linkend="boost_asio.reference.execution__can_start">execution::can_start</link></member>
<member><link linkend="boost_asio.reference.execution__can_submit">execution::can_submit</link></member>
<member><link linkend="boost_asio.reference.execution__connect_result">execution::connect_result</link></member>
<member><link linkend="boost_asio.reference.execution__is_executor">execution::is_executor</link></member>
<member><link linkend="boost_asio.reference.execution__is_executor_of">execution::is_executor_of</link></member>
<member><link linkend="boost_asio.reference.execution__is_nothrow_receiver_of">execution::is_nothrow_receiver_of</link></member>
<member><link linkend="boost_asio.reference.execution__is_receiver">execution::is_receiver</link></member>
<member><link linkend="boost_asio.reference.execution__is_receiver_of">execution::is_receiver_of</link></member>
<member><link linkend="boost_asio.reference.execution__is_sender">execution::is_sender</link></member>
<member><link linkend="boost_asio.reference.execution__is_sender_to">execution::is_sender_to</link></member>
<member><link linkend="boost_asio.reference.execution__is_typed_sender">execution::is_typed_sender</link></member>
<member><link linkend="boost_asio.reference.execution__sender_traits">execution::sender_traits</link></member>
</simplelist>
<bridgehead renderas="sect3">Concepts</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.Executor1.standard_executors">executor</link></member>
<member><link linkend="boost_asio.reference.Executor1.standard_executors">executor_of</link></member>
<member><link linkend="boost_asio.reference.OperationState">operation_state</link></member>
<member><link linkend="boost_asio.reference.Receiver">receiver</link></member>
<member><link linkend="boost_asio.reference.Receiver">receiver_of</link></member>
<member><link linkend="boost_asio.reference.Scheduler">scheduler</link></member>
<member><link linkend="boost_asio.reference.Sender">sender</link></member>
<member><link linkend="boost_asio.reference.Sender">sender_to</link></member>
<member><link linkend="boost_asio.reference.Sender.typed_sender">typed_sender</link></member>
</simplelist>
</entry>
</row>
</tbody>
</tgroup>
<tgroup cols="4">
<colspec colname="a"/>
<colspec colname="b"/>
<colspec colname="c"/>
<colspec colname="d"/>
<thead>
<row>
<entry valign="center" namest="a" nameend="d">
<bridgehead renderas="sect2">Core</bridgehead>
</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.any_io_executor">any_io_executor</link></member>
<member><link linkend="boost_asio.reference.bad_executor">bad_executor</link></member>
<member><link linkend="boost_asio.reference.cancellation_signal">cancellation_signal</link></member>
<member><link linkend="boost_asio.reference.cancellation_slot">cancellation_slot</link></member>
<member><link linkend="boost_asio.reference.cancellation_state">cancellation_state</link></member>
<member><link linkend="boost_asio.reference.cancellation_type">cancellation_type</link></member>
<member><link linkend="boost_asio.reference.coroutine">coroutine</link></member>
<member><link linkend="boost_asio.reference.detached_t">detached_t</link></member>
<member><link linkend="boost_asio.reference.execution_context">execution_context</link></member>
<member><link linkend="boost_asio.reference.execution_context__id">execution_context::id</link></member>
<member><link linkend="boost_asio.reference.execution_context__service">execution_context::service</link></member>
<member><link linkend="boost_asio.reference.executor">executor</link></member>
<member><link linkend="boost_asio.reference.executor_arg_t">executor_arg_t</link></member>
<member><link linkend="boost_asio.reference.invalid_service_owner">invalid_service_owner</link></member>
<member><link linkend="boost_asio.reference.io_context">io_context</link></member>
<member><link linkend="boost_asio.reference.io_context.executor_type">io_context::executor_type</link></member>
<member><link linkend="boost_asio.reference.io_context__service">io_context::service</link></member>
<member><link linkend="boost_asio.reference.io_context__strand">io_context::strand</link></member>
<member><link linkend="boost_asio.reference.io_context__work">io_context::work</link> (deprecated)</member>
<member><link linkend="boost_asio.reference.multiple_exceptions">multiple_exceptions</link></member>
<member><link linkend="boost_asio.reference.service_already_exists">service_already_exists</link></member>
<member><link linkend="boost_asio.reference.static_thread_pool">static_thread_pool</link></member>
<member><link linkend="boost_asio.reference.system_context">system_context</link></member>
<member><link linkend="boost_asio.reference.system_executor">system_executor</link></member>
<member><link linkend="boost_asio.reference.this_coro__executor_t">this_coro::executor_t</link></member>
<member><link linkend="boost_asio.reference.thread_pool">thread_pool</link></member>
<member><link linkend="boost_asio.reference.thread_pool.executor_type">thread_pool::executor_type</link></member>
<member><link linkend="boost_asio.reference.yield_context">yield_context</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Free Functions</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.execution_context.add_service">add_service</link></member>
<member><link linkend="boost_asio.reference.experimental__append">experimental::append</link></member>
<member><link linkend="boost_asio.reference.experimental__as_single">experimental::as_single</link></member>
<member><link linkend="boost_asio.reference.experimental__as_tuple">experimental::as_tuple</link></member>
<member><link linkend="boost_asio.reference.experimental__make_parallel_group">experimental::make_parallel_group</link></member>
<member><link linkend="boost_asio.reference.experimental__prepend">experimental::prepend</link></member>
<member><link linkend="boost_asio.reference.asio_handler_allocate">asio_handler_allocate</link> (deprecated)</member>
<member><link linkend="boost_asio.reference.asio_handler_deallocate">asio_handler_deallocate</link> (deprecated)</member>
<member><link linkend="boost_asio.reference.asio_handler_invoke">asio_handler_invoke</link> (deprecated)</member>
<member><link linkend="boost_asio.reference.asio_handler_is_continuation">asio_handler_is_continuation</link></member>
<member><link linkend="boost_asio.reference.async_compose">async_compose</link></member>
<member><link linkend="boost_asio.reference.async_initiate">async_initiate</link></member>
<member><link linkend="boost_asio.reference.bind_allocator">bind_allocator</link></member>
<member><link linkend="boost_asio.reference.bind_cancellation_slot">bind_cancellation_slot</link></member>
<member><link linkend="boost_asio.reference.bind_executor">bind_executor</link></member>
<member><link linkend="boost_asio.reference.co_spawn">co_spawn</link></member>
<member><link linkend="boost_asio.reference.dispatch">dispatch</link></member>
<member><link linkend="boost_asio.reference.defer">defer</link></member>
<member><link linkend="boost_asio.reference.get_associated_allocator">get_associated_allocator</link></member>
<member><link linkend="boost_asio.reference.get_associated_cancellation_slot">get_associated_cancellation_slot</link></member>
<member><link linkend="boost_asio.reference.get_associated_executor">get_associated_executor</link></member>
<member><link linkend="boost_asio.reference.execution_context.has_service">has_service</link></member>
<member><link linkend="boost_asio.reference.make_strand">make_strand</link></member>
<member><link linkend="boost_asio.reference.make_work_guard">make_work_guard</link></member>
<member><link linkend="boost_asio.reference.post">post</link></member>
<member><link linkend="boost_asio.reference.redirect_error">redirect_error</link></member>
<member><link linkend="boost_asio.reference.spawn">spawn</link></member>
<member><link linkend="boost_asio.reference.this_coro__reset_cancellation_state">this_coro::reset_cancellation_state</link></member>
<member><link linkend="boost_asio.reference.this_coro__throw_if_cancelled">this_coro::throw_if_cancelled</link></member>
<member><link linkend="boost_asio.reference.execution_context.use_service">use_service</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.async_completion">async_completion</link></member>
<member><link linkend="boost_asio.reference.awaitable">awaitable</link></member>
<member><link linkend="boost_asio.reference.basic_io_object">basic_io_object</link></member>
<member><link linkend="boost_asio.reference.basic_system_executor">basic_system_executor</link></member>
<member><link linkend="boost_asio.reference.basic_yield_context">basic_yield_context</link></member>
<member><link linkend="boost_asio.reference.cancellation_filter">cancellation_filter</link></member>
<member><link linkend="boost_asio.reference.cancellation_slot_binder">cancellation_slot_binder</link></member>
<member><link linkend="boost_asio.reference.experimental__deferred_t">experimental::deferred_t</link></member>
<member><link linkend="boost_asio.reference.executor_binder">executor_binder</link></member>
<member><link linkend="boost_asio.reference.executor_work_guard">executor_work_guard</link></member>
<member><link linkend="boost_asio.reference.experimental__append_t">experimental::append_t</link></member>
<member><link linkend="boost_asio.reference.experimental__as_single_t">experimental::as_single_t</link></member>
<member><link linkend="boost_asio.reference.experimental__as_tuple_t">experimental::as_tuple_t</link></member>
<member><link linkend="boost_asio.reference.experimental__basic_channel">experimental::basic_channel</link></member>
<member><link linkend="boost_asio.reference.experimental__basic_concurrent_channel">experimental::basic_concurrent_channel</link></member>
<member><link linkend="boost_asio.reference.experimental__channel_traits">experimental::channel_traits</link></member>
<member><link linkend="boost_asio.reference.experimental__coro">experimental::coro</link></member>
<member><link linkend="boost_asio.reference.experimental__parallel_group">experimental::parallel_group</link></member>
<member><link linkend="boost_asio.reference.experimental__prepend_t">experimental::prepend_t</link></member>
<member><link linkend="boost_asio.reference.experimental__promise_lt__void_lp_Ts_ellipsis__rp__comma__Executor__gt_">experimental::promise</link></member>
<member><link linkend="boost_asio.reference.experimental__use_coro_t">experimental::use_coro_t</link></member>
<member><link linkend="boost_asio.reference.experimental__wait_for_all">experimental::wait_for_all</link></member>
<member><link linkend="boost_asio.reference.experimental__wait_for_one">experimental::wait_for_one</link></member>
<member><link linkend="boost_asio.reference.experimental__wait_for_one_error">experimental::wait_for_one_error</link></member>
<member><link linkend="boost_asio.reference.experimental__wait_for_one_success">experimental::wait_for_one_success</link></member>
<member><link linkend="boost_asio.reference.io_context__basic_executor_type">io_context::basic_executor_type</link></member>
<member><link linkend="boost_asio.reference.recycling_allocator">recycling_allocator</link></member>
<member><link linkend="boost_asio.reference.redirect_error_t">redirect_error_t</link></member>
<member><link linkend="boost_asio.reference.strand">strand</link></member>
<member><link linkend="boost_asio.reference.thread_pool__basic_executor_type">thread_pool::basic_executor_type</link></member>
<member><link linkend="boost_asio.reference.use_awaitable_t">use_awaitable_t</link></member>
<member><link linkend="boost_asio.reference.use_future_t">use_future_t</link></member>
</simplelist>
<bridgehead renderas="sect3">Special Values</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.detached">detached</link></member>
<member><link linkend="boost_asio.reference.executor_arg">executor_arg</link></member>
<member><link linkend="boost_asio.reference.experimental__deferred">experimental::deferred</link></member>
<member><link linkend="boost_asio.reference.experimental__use_coro">experimental::use_coro</link></member>
<member><link linkend="boost_asio.reference.this_coro__cancellation_state">this_coro::cancellation_state</link></member>
<member><link linkend="boost_asio.reference.this_coro__executor">this_coro::executor</link></member>
<member><link linkend="boost_asio.reference.use_future">use_future</link></member>
<member><link linkend="boost_asio.reference.use_awaitable">use_awaitable</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Error Codes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.error__basic_errors">error::basic_errors</link></member>
<member><link linkend="boost_asio.reference.error__netdb_errors">error::netdb_errors</link></member>
<member><link linkend="boost_asio.reference.error__addrinfo_errors">error::addrinfo_errors</link></member>
<member><link linkend="boost_asio.reference.error__misc_errors">error::misc_errors</link></member>
</simplelist>
<bridgehead renderas="sect3">Boost.Bind Placeholders</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.placeholders__bytes_transferred">placeholders::bytes_transferred</link></member>
<member><link linkend="boost_asio.reference.placeholders__endpoint">placeholders::endpoint</link></member>
<member><link linkend="boost_asio.reference.placeholders__error">placeholders::error</link></member>
<member><link linkend="boost_asio.reference.placeholders__iterator">placeholders::iterator</link></member>
<member><link linkend="boost_asio.reference.placeholders__results">placeholders::results</link></member>
<member><link linkend="boost_asio.reference.placeholders__signal_number">placeholders::signal_number</link></member>
</simplelist>
<bridgehead renderas="sect3">Type Traits</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.associated_allocator">associated_allocator</link></member>
<member><link linkend="boost_asio.reference.associated_cancellation_slot">associated_cancellation_slot</link></member>
<member><link linkend="boost_asio.reference.associated_executor">associated_executor</link></member>
<member><link linkend="boost_asio.reference.associator">associator</link></member>
<member><link linkend="boost_asio.reference.async_result">async_result</link></member>
<member><link linkend="boost_asio.reference.default_completion_token">default_completion_token</link></member>
<member><link linkend="boost_asio.reference.is_executor">is_executor</link></member>
<member><link linkend="boost_asio.reference.uses_executor">uses_executor</link></member>
</simplelist>
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.asynchronous_operations">Asynchronous operations</link></member>
<member><link linkend="boost_asio.reference.CancellationHandler">CancellationHandler</link></member>
<member><link linkend="boost_asio.reference.CancellationSlot">CancellationSlot</link></member>
<member><link linkend="boost_asio.reference.ExecutionContext">ExecutionContext</link></member>
<member><link linkend="boost_asio.reference.Executor1">Executor</link></member>
<member><link linkend="boost_asio.reference.Handler">Handler</link></member>
<member><link linkend="boost_asio.reference.NullaryToken">NullaryToken</link></member>
<member><link linkend="boost_asio.reference.Service">Service</link></member>
</simplelist>
</entry>
</row>
</tbody>
</tgroup>
<tgroup cols="4">
<colspec colname="a"/>
<colspec colname="b"/>
<colspec colname="c"/>
<colspec colname="d"/>
<thead>
<row>
<entry valign="center" namest="a" nameend="d">
<bridgehead renderas="sect2">Buffers and Buffer-Oriented Operations</bridgehead>
</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.const_buffer">const_buffer</link></member>
<member><link linkend="boost_asio.reference.mutable_buffer">mutable_buffer</link></member>
<member><link linkend="boost_asio.reference.const_buffers_1">const_buffers_1 </link> (deprecated)</member>
<member><link linkend="boost_asio.reference.mutable_buffers_1">mutable_buffers_1 </link> (deprecated)</member>
<member><link linkend="boost_asio.reference.const_registered_buffer">const_registered_buffer</link></member>
<member><link linkend="boost_asio.reference.mutable_registered_buffer">mutable_registered_buffer</link></member>
<member><link linkend="boost_asio.reference.null_buffers">null_buffers</link> (deprecated)</member>
<member><link linkend="boost_asio.reference.streambuf">streambuf</link></member>
<member><link linkend="boost_asio.reference.registered_buffer_id">registered_buffer_id</link></member>
</simplelist>
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.basic_streambuf">basic_streambuf</link></member>
<member><link linkend="boost_asio.reference.buffer_registration">buffer_registration</link></member>
<member><link linkend="boost_asio.reference.buffered_read_stream">buffered_read_stream</link></member>
<member><link linkend="boost_asio.reference.buffered_stream">buffered_stream</link></member>
<member><link linkend="boost_asio.reference.buffered_write_stream">buffered_write_stream</link></member>
<member><link linkend="boost_asio.reference.buffers_iterator">buffers_iterator</link></member>
<member><link linkend="boost_asio.reference.dynamic_string_buffer">dynamic_string_buffer</link></member>
<member><link linkend="boost_asio.reference.dynamic_vector_buffer">dynamic_vector_buffer</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Free Functions</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.async_read">async_read</link></member>
<member><link linkend="boost_asio.reference.async_read_at">async_read_at</link></member>
<member><link linkend="boost_asio.reference.async_read_until">async_read_until</link></member>
<member><link linkend="boost_asio.reference.async_write">async_write</link></member>
<member><link linkend="boost_asio.reference.async_write_at">async_write_at</link></member>
<member><link linkend="boost_asio.reference.buffer">buffer</link></member>
<member><link linkend="boost_asio.reference.buffer_cast">buffer_cast </link> (deprecated)</member>
<member><link linkend="boost_asio.reference.buffer_copy">buffer_copy</link></member>
<member><link linkend="boost_asio.reference.buffer_size">buffer_size</link></member>
<member><link linkend="boost_asio.reference.buffer_sequence_begin">buffer_sequence_begin</link></member>
<member><link linkend="boost_asio.reference.buffer_sequence_end">buffer_sequence_end</link></member>
<member><link linkend="boost_asio.reference.buffers_begin">buffers_begin</link></member>
<member><link linkend="boost_asio.reference.buffers_end">buffers_end</link></member>
<member><link linkend="boost_asio.reference.dynamic_buffer">dynamic_buffer</link></member>
<member><link linkend="boost_asio.reference.read">read</link></member>
<member><link linkend="boost_asio.reference.read_at">read_at</link></member>
<member><link linkend="boost_asio.reference.read_until">read_until</link></member>
<member><link linkend="boost_asio.reference.register_buffers">register_buffers</link></member>
<member><link linkend="boost_asio.reference.transfer_all">transfer_all</link></member>
<member><link linkend="boost_asio.reference.transfer_at_least">transfer_at_least</link></member>
<member><link linkend="boost_asio.reference.transfer_exactly">transfer_exactly</link></member>
<member><link linkend="boost_asio.reference.write">write</link></member>
<member><link linkend="boost_asio.reference.write_at">write_at</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Type Traits</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.is_const_buffer_sequence">is_const_buffer_sequence</link></member>
<member><link linkend="boost_asio.reference.is_dynamic_buffer">is_dynamic_buffer</link></member>
<member><link linkend="boost_asio.reference.is_dynamic_buffer_v1">is_dynamic_buffer_v1</link></member>
<member><link linkend="boost_asio.reference.is_dynamic_buffer_v2">is_dynamic_buffer_v2</link></member>
<member><link linkend="boost_asio.reference.is_match_condition">is_match_condition</link></member>
<member><link linkend="boost_asio.reference.is_mutable_buffer_sequence">is_mutable_buffer_sequence</link></member>
<member><link linkend="boost_asio.reference.is_read_buffered">is_read_buffered</link></member>
<member><link linkend="boost_asio.reference.is_write_buffered">is_write_buffered</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.read_write_operations">Read and write operations</link></member>
<member><link linkend="boost_asio.reference.AsyncRandomAccessReadDevice">AsyncRandomAccessReadDevice</link></member>
<member><link linkend="boost_asio.reference.AsyncRandomAccessWriteDevice">AsyncRandomAccessWriteDevice</link></member>
<member><link linkend="boost_asio.reference.AsyncReadStream">AsyncReadStream</link></member>
<member><link linkend="boost_asio.reference.AsyncWriteStream">AsyncWriteStream</link></member>
<member><link linkend="boost_asio.reference.CompletionCondition">CompletionCondition</link></member>
<member><link linkend="boost_asio.reference.ConstBufferSequence">ConstBufferSequence</link></member>
<member><link linkend="boost_asio.reference.DynamicBuffer">DynamicBuffer</link></member>
<member><link linkend="boost_asio.reference.DynamicBuffer_v1">DynamicBuffer_v1</link></member>
<member><link linkend="boost_asio.reference.DynamicBuffer_v2">DynamicBuffer_v2</link></member>
<member><link linkend="boost_asio.reference.MutableBufferSequence">MutableBufferSequence</link></member>
<member><link linkend="boost_asio.reference.ReadHandler">ReadHandler</link></member>
<member><link linkend="boost_asio.reference.ReadToken">ReadToken</link></member>
<member><link linkend="boost_asio.reference.SyncRandomAccessReadDevice">SyncRandomAccessReadDevice</link></member>
<member><link linkend="boost_asio.reference.SyncRandomAccessWriteDevice">SyncRandomAccessWriteDevice</link></member>
<member><link linkend="boost_asio.reference.SyncReadStream">SyncReadStream</link></member>
<member><link linkend="boost_asio.reference.SyncWriteStream">SyncWriteStream</link></member>
<member><link linkend="boost_asio.reference.WriteHandler">WriteHandler</link></member>
<member><link linkend="boost_asio.reference.WriteToken">WriteToken</link></member>
</simplelist>
</entry>
</row>
</tbody>
</tgroup>
<tgroup cols="4">
<colspec colname="a"/>
<colspec colname="b"/>
<colspec colname="c"/>
<colspec colname="d"/>
<thead>
<row>
<entry valign="center" namest="a" nameend="d">
<bridgehead renderas="sect2">Networking</bridgehead>
</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.generic__datagram_protocol">generic::datagram_protocol</link></member>
<member><link linkend="boost_asio.reference.generic__datagram_protocol.endpoint">generic::datagram_protocol::endpoint</link></member>
<member><link linkend="boost_asio.reference.generic__datagram_protocol.socket">generic::datagram_protocol::socket</link></member>
<member><link linkend="boost_asio.reference.generic__raw_protocol">generic::raw_protocol</link></member>
<member><link linkend="boost_asio.reference.generic__raw_protocol.endpoint">generic::raw_protocol::endpoint</link></member>
<member><link linkend="boost_asio.reference.generic__raw_protocol.socket">generic::raw_protocol::socket</link></member>
<member><link linkend="boost_asio.reference.generic__seq_packet_protocol">generic::seq_packet_protocol</link></member>
<member><link linkend="boost_asio.reference.generic__seq_packet_protocol.endpoint">generic::seq_packet_protocol::endpoint</link></member>
<member><link linkend="boost_asio.reference.generic__seq_packet_protocol.socket">generic::seq_packet_protocol::socket</link></member>
<member><link linkend="boost_asio.reference.generic__stream_protocol">generic::stream_protocol</link></member>
<member><link linkend="boost_asio.reference.generic__stream_protocol.endpoint">generic::stream_protocol::endpoint</link></member>
<member><link linkend="boost_asio.reference.generic__stream_protocol.iostream">generic::stream_protocol::iostream</link></member>
<member><link linkend="boost_asio.reference.generic__stream_protocol.socket">generic::stream_protocol::socket</link></member>
<member><link linkend="boost_asio.reference.ip__address">ip::address</link></member>
<member><link linkend="boost_asio.reference.ip__address_v4">ip::address_v4</link></member>
<member><link linkend="boost_asio.reference.ip__address_v4_iterator">ip::address_v4_iterator</link></member>
<member><link linkend="boost_asio.reference.ip__address_v4_range">ip::address_v4_range</link></member>
<member><link linkend="boost_asio.reference.ip__address_v6">ip::address_v6</link></member>
<member><link linkend="boost_asio.reference.ip__address_v6_iterator">ip::address_v6_iterator</link></member>
<member><link linkend="boost_asio.reference.ip__address_v6_range">ip::address_v6_range</link></member>
<member><link linkend="boost_asio.reference.ip__bad_address_cast">ip::bad_address_cast</link></member>
<member><link linkend="boost_asio.reference.ip__icmp">ip::icmp</link></member>
<member><link linkend="boost_asio.reference.ip__icmp.endpoint">ip::icmp::endpoint</link></member>
<member><link linkend="boost_asio.reference.ip__icmp.resolver">ip::icmp::resolver</link></member>
<member><link linkend="boost_asio.reference.ip__icmp.socket">ip::icmp::socket</link></member>
<member><link linkend="boost_asio.reference.ip__network_v4">ip::network_v4</link></member>
<member><link linkend="boost_asio.reference.ip__network_v6">ip::network_v6</link></member>
<member><link linkend="boost_asio.reference.ip__resolver_base">ip::resolver_base</link></member>
<member><link linkend="boost_asio.reference.ip__resolver_query_base">ip::resolver_query_base</link></member>
<member><link linkend="boost_asio.reference.ip__tcp">ip::tcp</link></member>
<member><link linkend="boost_asio.reference.ip__tcp.acceptor">ip::tcp::acceptor</link></member>
<member><link linkend="boost_asio.reference.ip__tcp.endpoint">ip::tcp::endpoint</link></member>
<member><link linkend="boost_asio.reference.ip__tcp.iostream">ip::tcp::iostream</link></member>
<member><link linkend="boost_asio.reference.ip__tcp.resolver">ip::tcp::resolver</link></member>
<member><link linkend="boost_asio.reference.ip__tcp.socket">ip::tcp::socket</link></member>
<member><link linkend="boost_asio.reference.ip__udp">ip::udp</link></member>
<member><link linkend="boost_asio.reference.ip__udp.endpoint">ip::udp::endpoint</link></member>
<member><link linkend="boost_asio.reference.ip__udp.resolver">ip::udp::resolver</link></member>
<member><link linkend="boost_asio.reference.ip__udp.socket">ip::udp::socket</link></member>
<member><link linkend="boost_asio.reference.ip__v4_mapped_t">ip::v4_mapped_t</link></member>
<member><link linkend="boost_asio.reference.socket_base">socket_base</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Free Functions</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.async_connect">async_connect</link></member>
<member><link linkend="boost_asio.reference.connect">connect</link></member>
<member><link linkend="boost_asio.reference.ip__host_name">ip::host_name</link></member>
<member><link linkend="boost_asio.reference.ip__address.make_address">ip::make_address</link></member>
<member><link linkend="boost_asio.reference.ip__address_v4.make_address_v4">ip::make_address_v4</link></member>
<member><link linkend="boost_asio.reference.ip__address_v6.make_address_v6">ip::make_address_v6</link></member>
<member><link linkend="boost_asio.reference.ip__network_v4.make_network_v4">ip::make_network_v4</link></member>
<member><link linkend="boost_asio.reference.ip__network_v6.make_network_v6">ip::make_network_v6</link></member>
</simplelist>
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.basic_datagram_socket">basic_datagram_socket</link></member>
<member><link linkend="boost_asio.reference.basic_raw_socket">basic_raw_socket</link></member>
<member><link linkend="boost_asio.reference.basic_seq_packet_socket">basic_seq_packet_socket</link></member>
<member><link linkend="boost_asio.reference.basic_socket">basic_socket</link></member>
<member><link linkend="boost_asio.reference.basic_socket_acceptor">basic_socket_acceptor</link></member>
<member><link linkend="boost_asio.reference.basic_socket_iostream">basic_socket_iostream</link></member>
<member><link linkend="boost_asio.reference.basic_socket_streambuf">basic_socket_streambuf</link></member>
<member><link linkend="boost_asio.reference.basic_stream_socket">basic_stream_socket</link></member>
<member><link linkend="boost_asio.reference.generic__basic_endpoint">generic::basic_endpoint</link></member>
<member><link linkend="boost_asio.reference.ip__basic_endpoint">ip::basic_endpoint</link></member>
<member><link linkend="boost_asio.reference.ip__basic_resolver">ip::basic_resolver</link></member>
<member><link linkend="boost_asio.reference.ip__basic_resolver_entry">ip::basic_resolver_entry</link></member>
<member><link linkend="boost_asio.reference.ip__basic_resolver_iterator">ip::basic_resolver_iterator</link></member>
<member><link linkend="boost_asio.reference.ip__basic_resolver_results">ip::basic_resolver_results</link></member>
<member><link linkend="boost_asio.reference.ip__basic_resolver_query">ip::basic_resolver_query</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Socket Options</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.ip__multicast__enable_loopback">ip::multicast::enable_loopback</link></member>
<member><link linkend="boost_asio.reference.ip__multicast__hops">ip::multicast::hops</link></member>
<member><link linkend="boost_asio.reference.ip__multicast__join_group">ip::multicast::join_group</link></member>
<member><link linkend="boost_asio.reference.ip__multicast__leave_group">ip::multicast::leave_group</link></member>
<member><link linkend="boost_asio.reference.ip__multicast__outbound_interface">ip::multicast::outbound_interface</link></member>
<member><link linkend="boost_asio.reference.ip__tcp.no_delay">ip::tcp::no_delay</link></member>
<member><link linkend="boost_asio.reference.ip__unicast__hops">ip::unicast::hops</link></member>
<member><link linkend="boost_asio.reference.ip__v6_only">ip::v6_only</link></member>
<member><link linkend="boost_asio.reference.socket_base.broadcast">socket_base::broadcast</link></member>
<member><link linkend="boost_asio.reference.socket_base.debug">socket_base::debug</link></member>
<member><link linkend="boost_asio.reference.socket_base.do_not_route">socket_base::do_not_route</link></member>
<member><link linkend="boost_asio.reference.socket_base.enable_connection_aborted">socket_base::enable_connection_aborted</link></member>
<member><link linkend="boost_asio.reference.socket_base.keep_alive">socket_base::keep_alive</link></member>
<member><link linkend="boost_asio.reference.socket_base.linger">socket_base::linger</link></member>
<member><link linkend="boost_asio.reference.socket_base.receive_buffer_size">socket_base::receive_buffer_size</link></member>
<member><link linkend="boost_asio.reference.socket_base.receive_low_watermark">socket_base::receive_low_watermark</link></member>
<member><link linkend="boost_asio.reference.socket_base.reuse_address">socket_base::reuse_address</link></member>
<member><link linkend="boost_asio.reference.socket_base.send_buffer_size">socket_base::send_buffer_size</link></member>
<member><link linkend="boost_asio.reference.socket_base.send_low_watermark">socket_base::send_low_watermark</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">I/O Control Commands</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.socket_base.bytes_readable">socket_base::bytes_readable</link></member>
</simplelist>
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.synchronous_socket_operations">Synchronous socket operations</link></member>
<member><link linkend="boost_asio.reference.asynchronous_socket_operations">Asynchronous socket operations</link></member>
<member><link linkend="boost_asio.reference.AcceptableProtocol">AcceptableProtocol</link></member>
<member><link linkend="boost_asio.reference.AcceptHandler">AcceptHandler</link></member>
<member><link linkend="boost_asio.reference.AcceptToken">AcceptToken</link></member>
<member><link linkend="boost_asio.reference.ConnectCondition">ConnectCondition</link></member>
<member><link linkend="boost_asio.reference.ConnectHandler">ConnectHandler</link></member>
<member><link linkend="boost_asio.reference.ConnectToken">ConnectToken</link></member>
<member><link linkend="boost_asio.reference.Endpoint">Endpoint</link></member>
<member><link linkend="boost_asio.reference.EndpointSequence">EndpointSequence</link></member>
<member><link linkend="boost_asio.reference.GettableSocketOption">GettableSocketOption</link></member>
<member><link linkend="boost_asio.reference.InternetProtocol">InternetProtocol</link></member>
<member><link linkend="boost_asio.reference.IoControlCommand">IoControlCommand</link></member>
<member><link linkend="boost_asio.reference.IteratorConnectHandler">IteratorConnectHandler</link></member>
<member><link linkend="boost_asio.reference.IteratorConnectToken">IteratorConnectToken</link></member>
<member><link linkend="boost_asio.reference.MoveAcceptHandler">MoveAcceptHandler</link></member>
<member><link linkend="boost_asio.reference.MoveAcceptToken">MoveAcceptToken</link></member>
<member><link linkend="boost_asio.reference.Protocol">Protocol</link></member>
<member><link linkend="boost_asio.reference.RangeConnectHandler">RangeConnectHandler</link></member>
<member><link linkend="boost_asio.reference.RangeConnectToken">RangeConnectToken</link></member>
<member><link linkend="boost_asio.reference.ResolveHandler">ResolveHandler</link></member>
<member><link linkend="boost_asio.reference.ResolveToken">ResolveToken</link></member>
<member><link linkend="boost_asio.reference.SettableSocketOption">SettableSocketOption</link></member>
</simplelist>
</entry>
</row>
</tbody>
</tgroup>
<tgroup cols="4">
<colspec colname="a"/>
<colspec colname="b"/>
<colspec colname="c"/>
<colspec colname="d"/>
<thead>
<row>
<entry valign="center" namest="a" nameend="a">
<bridgehead renderas="sect2">Timers</bridgehead>
</entry>
<entry valign="center" namest="b" nameend="b">
<bridgehead renderas="sect2">SSL</bridgehead>
</entry>
<entry valign="center" namest="c" nameend="c">
<bridgehead renderas="sect2">Serial Ports</bridgehead>
</entry>
<entry valign="center" namest="d" nameend="d">
<bridgehead renderas="sect2">Signal Handling</bridgehead>
</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.deadline_timer">deadline_timer</link></member>
<member><link linkend="boost_asio.reference.high_resolution_timer">high_resolution_timer</link></member>
<member><link linkend="boost_asio.reference.steady_timer">steady_timer</link></member>
<member><link linkend="boost_asio.reference.system_timer">system_timer</link></member>
</simplelist>
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.basic_deadline_timer">basic_deadline_timer</link></member>
<member><link linkend="boost_asio.reference.basic_waitable_timer">basic_waitable_timer</link></member>
<member><link linkend="boost_asio.reference.time_traits_lt__ptime__gt_">time_traits</link></member>
<member><link linkend="boost_asio.reference.wait_traits">wait_traits</link></member>
</simplelist>
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.TimeTraits">TimeTraits</link></member>
<member><link linkend="boost_asio.reference.WaitHandler">WaitHandler</link></member>
<member><link linkend="boost_asio.reference.WaitToken">WaitToken</link></member>
<member><link linkend="boost_asio.reference.WaitTraits">WaitTraits</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.ssl__context">ssl::context</link></member>
<member><link linkend="boost_asio.reference.ssl__context_base">ssl::context_base</link></member>
<member><link linkend="boost_asio.reference.ssl__host_name_verification">ssl::host_name_verification</link></member>
<member><link linkend="boost_asio.reference.ssl__rfc2818_verification">ssl::rfc2818_verification</link> (deprecated)</member>
<member><link linkend="boost_asio.reference.ssl__stream_base">ssl::stream_base</link></member>
<member><link linkend="boost_asio.reference.ssl__verify_context">ssl::verify_context</link></member>
</simplelist>
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.ssl__stream">ssl::stream</link></member>
</simplelist>
<bridgehead renderas="sect3">Error Codes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.ssl__error__stream_errors">ssl::error::stream_errors</link></member>
</simplelist>
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.BufferedHandshakeHandler">BufferedHandshakeHandler</link></member>
<member><link linkend="boost_asio.reference.BufferedHandshakeToken">BufferedHandshakeToken</link></member>
<member><link linkend="boost_asio.reference.HandshakeHandler">HandshakeHandler</link></member>
<member><link linkend="boost_asio.reference.HandshakeToken">HandshakeToken</link></member>
<member><link linkend="boost_asio.reference.ShutdownHandler">ShutdownHandler</link></member>
<member><link linkend="boost_asio.reference.ShutdownToken">ShutdownToken</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.serial_port">serial_port</link></member>
<member><link linkend="boost_asio.reference.serial_port_base">serial_port_base</link></member>
</simplelist>
<bridgehead renderas="sect3">Class templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.basic_serial_port">basic_serial_port</link></member>
</simplelist>
<bridgehead renderas="sect3">Serial Port Options</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.serial_port_base__baud_rate">serial_port_base::baud_rate</link></member>
<member><link linkend="boost_asio.reference.serial_port_base__flow_control">serial_port_base::flow_control</link></member>
<member><link linkend="boost_asio.reference.serial_port_base__parity">serial_port_base::parity</link></member>
<member><link linkend="boost_asio.reference.serial_port_base__stop_bits">serial_port_base::stop_bits</link></member>
<member><link linkend="boost_asio.reference.serial_port_base__character_size">serial_port_base::character_size</link></member>
</simplelist>
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.GettableSerialPortOption">GettableSerialPortOption</link></member>
<member><link linkend="boost_asio.reference.SettableSerialPortOption">SettableSerialPortOption</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.signal_set">signal_set</link></member>
</simplelist>
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.basic_signal_set">basic_signal_set</link></member>
</simplelist>
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.SignalHandler">SignalHandler</link></member>
<member><link linkend="boost_asio.reference.SignalToken">SignalToken</link></member>
</simplelist>
</entry>
</row>
</tbody>
</tgroup>
<tgroup cols="4">
<colspec colname="a"/>
<colspec colname="b"/>
<colspec colname="c"/>
<colspec colname="d"/>
<thead>
<row>
<entry valign="center" namest="a" nameend="a">
<bridgehead renderas="sect2">Files and Pipes</bridgehead>
</entry>
<entry valign="center" namest="b" nameend="c">
<bridgehead renderas="sect2">POSIX-specific</bridgehead>
</entry>
<entry valign="center" namest="d" nameend="d">
<bridgehead renderas="sect2">Windows-specific</bridgehead>
</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top">
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.basic_file">basic_file</link></member>
<member><link linkend="boost_asio.reference.basic_random_access_file">basic_random_access_file</link></member>
<member><link linkend="boost_asio.reference.basic_readable_pipe">basic_readable_pipe</link></member>
<member><link linkend="boost_asio.reference.basic_stream_file">basic_stream_file</link></member>
<member><link linkend="boost_asio.reference.basic_writable_pipe">basic_writable_pipe</link></member>
</simplelist>
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.file_base">file_base</link></member>
<member><link linkend="boost_asio.reference.random_access_file">random_access_file</link></member>
<member><link linkend="boost_asio.reference.readable_pipe">readable_pipe</link></member>
<member><link linkend="boost_asio.reference.stream_file">stream_file</link></member>
<member><link linkend="boost_asio.reference.writable_pipe">writable_pipe</link></member>
</simplelist>
<bridgehead renderas="sect3">Free Functions</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.connect_pipe">connect_pipe</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.local__stream_protocol">local::stream_protocol</link></member>
<member><link linkend="boost_asio.reference.local__stream_protocol.acceptor">local::stream_protocol::acceptor</link></member>
<member><link linkend="boost_asio.reference.local__stream_protocol.endpoint">local::stream_protocol::endpoint</link></member>
<member><link linkend="boost_asio.reference.local__stream_protocol.iostream">local::stream_protocol::iostream</link></member>
<member><link linkend="boost_asio.reference.local__stream_protocol.socket">local::stream_protocol::socket</link></member>
<member><link linkend="boost_asio.reference.local__datagram_protocol">local::datagram_protocol</link></member>
<member><link linkend="boost_asio.reference.local__datagram_protocol.endpoint">local::datagram_protocol::endpoint</link></member>
<member><link linkend="boost_asio.reference.local__datagram_protocol.socket">local::datagram_protocol::socket</link></member>
<member><link linkend="boost_asio.reference.posix__descriptor">posix::descriptor</link></member>
<member><link linkend="boost_asio.reference.posix__descriptor_base">posix::descriptor_base</link></member>
<member><link linkend="boost_asio.reference.posix__stream_descriptor">posix::stream_descriptor</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Free Functions</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.local__connect_pair">local::connect_pair</link></member>
</simplelist>
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.local__basic_endpoint">local::basic_endpoint</link></member>
<member><link linkend="boost_asio.reference.posix__basic_descriptor">posix::basic_descriptor</link></member>
<member><link linkend="boost_asio.reference.posix__basic_stream_descriptor">posix::basic_stream_descriptor</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.windows__object_handle">windows::object_handle</link></member>
<member><link linkend="boost_asio.reference.windows__overlapped_handle">windows::overlapped_handle</link></member>
<member><link linkend="boost_asio.reference.windows__overlapped_ptr">windows::overlapped_ptr</link></member>
<member><link linkend="boost_asio.reference.windows__random_access_handle">windows::random_access_handle</link></member>
<member><link linkend="boost_asio.reference.windows__stream_handle">windows::stream_handle</link></member>
</simplelist>
<bridgehead renderas="sect3">Class Templates</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.windows__basic_object_handle">windows::basic_object_handle</link></member>
<member><link linkend="boost_asio.reference.windows__basic_overlapped_handle">windows::basic_overlapped_handle</link></member>
<member><link linkend="boost_asio.reference.windows__basic_random_access_handle">windows::basic_random_access_handle</link></member>
<member><link linkend="boost_asio.reference.windows__basic_stream_handle">windows::basic_stream_handle</link></member>
</simplelist>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>

View File

@@ -0,0 +1,275 @@
# Doxyfile 1.4.5
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Boost.Asio Reference"
PROJECT_NUMBER =
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = YES
INLINE_INHERITED_MEMB = YES
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = ./../../../
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = YES
DETAILS_AT_TOP = YES
INHERIT_DOCS = NO
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 2
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = NO
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = NO
INLINE_INFO = NO
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = NO
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= NO
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = NO
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ./../../../boost/asio.hpp \
./../../../boost/asio \
./../../../boost/asio/generic \
./../../../boost/asio/impl \
./../../../boost/asio/ip \
./../../../boost/asio/local \
./../../../boost/asio/posix \
./../../../boost/asio/ssl \
./../../../boost/asio/windows \
./../../../boost/asio/execution \
./../../../boost/asio/experimental \
./model_dox.txt \
./noncopyable_dox.txt \
./std_exception_dox.txt
FILE_PATTERNS =
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = YES
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
USE_HTAGS = NO
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 1
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = NO
HTML_OUTPUT = .
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = YES
ENUM_VALUES_PER_LINE = 1
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = YES
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = NO
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = GENERATING_DOCUMENTATION \
BOOST_ASIO_SOCKET_ERROR(e)=implementation_defined \
BOOST_ASIO_NETDB_ERROR(e)=implementation_defined \
BOOST_ASIO_EOF_ERROR(e)=implementation_defined \
BOOST_ASIO_OS_ERROR(e1,e2)=implementation_defined \
BOOST_ASIO_MOVE_ARG(a)=a&& \
BOOST_ASIO_NONDEDUCED_MOVE_ARG(a)=a& \
BOOST_ASIO_DECL= \
BOOST_ASIO_CONSTEXPR=constexpr \
BOOST_ASIO_NOEXCEPT=noexcept \
BOOST_ASIO_NODISCARD= \
BOOST_ASIO_COMPLETION_SIGNATURE=typename \
BOOST_ASIO_COMPLETION_HANDLER_FOR(s)=typename \
BOOST_ASIO_COMPLETION_TOKEN_FOR(s)=typename \
BOOST_ASIO_COMPLETION_SIGNATURES_TPARAMS="typename... Signatures" \
BOOST_ASIO_COMPLETION_SIGNATURES_TARGS=Signatures... \
BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=void_or_deduced \
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(t,a)=void_or_deduced \
BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(e)==default_token \
BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(e)==default_token \
BOOST_ASIO_SVC_TPARAM= \
BOOST_ASIO_SVC_TPARAM_DEF1()= \
BOOST_ASIO_SVC_TPARAM_DEF2()= \
BOOST_ASIO_SVC_TARG= \
BOOST_ASIO_SVC_TPARAM1= \
BOOST_ASIO_SVC_TPARAM1_DEF1()= \
BOOST_ASIO_SVC_TPARAM1_DEF2()= \
BOOST_ASIO_SVC_TARG1= \
BOOST_ASIO_SVC_T=asio::detail::service \
BOOST_ASIO_SVC_T1=asio::detail::service \
BOOST_ASIO_CONST_BUFFER=const_buffer \
BOOST_ASIO_MUTABLE_BUFFER=mutable_buffer \
BOOST_ASIO_SYNC_OP_VOID=void \
BOOST_ASIO_STRING_VIEW_PARAM=string_view \
BOOST_ASIO_UNUSED_VARIABLE= \
BOOST_ASIO_UNSPECIFIED(e)=unspecified \
BOOST_ASIO_EXECUTION_EXECUTOR=typename \
BOOST_ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT==std::exception_ptr \
BOOST_ASIO_EXECUTION_RECEIVER_OF_0=typename \
BOOST_ASIO_NOEXCEPT_IF(c)=
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE = reference.tags
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = NO
GROUP_GRAPHS = NO
UML_LOOK = NO
TEMPLATE_RELATIONS = YES
INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = NO
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = NO
DIRECTORY_GRAPH = NO
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 640
MAX_DOT_GRAPH_HEIGHT = 640
MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = NO
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,180 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:requirements Type Requirements]
Throughout this documentation, the names of the template parameters are used to
express type requirements, as listed in the table below.
[table Template parameters and type requirements
[[Template Parameter Name][Type Requirements]]
[
[`AcceptHandler`]
[[link boost_asio.requirements.AcceptHandler accept handler]]
]
[
[`AsyncReadStream`]
[[link boost_asio.requirements.AsyncReadStream buffer-oriented asynchronous
read stream]]
]
[
[`AsyncWriteStream`]
[[link boost_asio.requirements.AsyncWriteStream buffer-oriented asynchronous
write stream]]
]
[
[`CompletionHandler`]
[[link boost_asio.requirements.CompletionHandler completion handler]]
]
[
[`ConnectHandler`]
[[link boost_asio.requirements.ConnectHandler connect handler]]
]
[
[`ConstBufferSequence`]
[[link boost_asio.requirements.ConstBufferSequence constant buffer
sequence]]
]
[
[`ConvertibleToConstBuffer`]
[[link boost_asio.requirements.ConvertibleToConstBuffer convertible to a
constant buffer]]
]
[
[`ConvertibleToMutableBuffer`]
[[link boost_asio.requirements.ConvertibleToMutableBuffer convertible to a
mutable buffer]]
]
[
[`DatagramSocketService`]
[[link boost_asio.requirements.DatagramSocketService datagram socket
service]]
]
[
[`GettableSocketOption`]
[[link boost_asio.requirements.GettableSocketOption gettable socket option]]
]
[
[`Handler`]
[[link boost_asio.requirements.Handler handler]]
]
[
[`InternetProtocol`]
[[link boost_asio.requirements.InternetProtocol Internet protocol]]
]
[
[`IoControlCommand`]
[[link boost_asio.requirements.IoControlCommand I/O control command]]
]
[
[`IoObjectService`]
[[link boost_asio.requirements.IoObjectService I/O object service]]
]
[
[`MutableBufferSequence`]
[[link boost_asio.requirements.MutableBufferSequence mutable buffer
sequence]]
]
[
[`Protocol`]
[[link boost_asio.requirements.Protocol protocol]]
]
[
[`ReadHandler`]
[[link boost_asio.requirements.ReadHandler read handler]]
]
[
[`ResolveHandler`]
[[link boost_asio.requirements.ResolveHandler resolve handler]]
]
[
[`ResolverService`]
[[link boost_asio.requirements.ResolverService resolver service]]
]
[
[`Service`]
[[link boost_asio.requirements.Service service]]
]
[
[`SettableSocketOption`]
[[link boost_asio.requirements.SettableSocketOption settable socket option]]
]
[
[`SocketAcceptorService`]
[[link boost_asio.requirements.SocketAcceptorService socket acceptor
service]]
]
[
[`SocketService`]
[[link boost_asio.requirements.SocketService socket service]]
]
[
[`StreamSocketService`]
[[link boost_asio.requirements.StreamSocketService stream socket service]]
]
[
[`SyncReadStream`]
[[link boost_asio.requirements.SyncReadStream buffer-oriented synchronous
read stream]]
]
[
[`SyncWriteStream`]
[[link boost_asio.requirements.SyncWriteStream buffer-oriented synchronous
write stream]]
]
[
[`TimerService`]
[[link boost_asio.requirements.TimerService timer service]]
]
[
[`TimeTraits`]
[[link boost_asio.requirements.TimeTraits time traits]]
]
[
[`WaitHandler`]
[[link boost_asio.requirements.WaitHandler wait handler]]
]
[
[`WriteHandler`]
[[link boost_asio.requirements.WriteHandler write handler]]
]
]
[include requirements/asynchronous_operations.qbk]
[include requirements/AcceptHandler.qbk]
[include requirements/AsyncReadStream.qbk]
[include requirements/AsyncWriteStream.qbk]
[include requirements/CompletionHandler.qbk]
[include requirements/ConnectHandler.qbk]
[include requirements/ConstBufferSequence.qbk]
[include requirements/ConvertibleToConstBuffer.qbk]
[include requirements/ConvertibleToMutableBuffer.qbk]
[include requirements/DatagramSocketService.qbk]
[include requirements/Endpoint.qbk]
[include requirements/GettableSocketOption.qbk]
[include requirements/Handler.qbk]
[include requirements/InternetProtocol.qbk]
[include requirements/IoControlCommand.qbk]
[include requirements/IoObjectService.qbk]
[include requirements/MutableBufferSequence.qbk]
[include requirements/Protocol.qbk]
[include requirements/ReadHandler.qbk]
[include requirements/ResolveHandler.qbk]
[include requirements/ResolverService.qbk]
[include requirements/Service.qbk]
[include requirements/SettableSocketOption.qbk]
[include requirements/SocketAcceptorService.qbk]
[include requirements/SocketService.qbk]
[include requirements/StreamSocketService.qbk]
[include requirements/SyncReadStream.qbk]
[include requirements/SyncWriteStream.qbk]
[include requirements/TimeTraits.qbk]
[include requirements/TimerService.qbk]
[include requirements/WaitHandler.qbk]
[include requirements/WriteHandler.qbk]
[endsect]

View File

@@ -0,0 +1,15 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:AcceptHandler Accept handler requirements]
An accept handler must meet the requirements for a [link
boost_asio.reference.Handler handler]. A value `h` of an accept handler
class should work correctly in the expression `h(ec)`, where `ec` is an lvalue
of type `const error_code`.
[endsect]

View File

@@ -0,0 +1,99 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:AcceptToken Accept token requirements]
A accept token is a [link boost_asio.overview.model.completion_tokens completion
token] for completion signature `void(error_code)`.
[heading Examples]
A free function as a accept token:
void accept_handler(
const boost::system::error_code& ec)
{
...
}
A accept token function object:
struct accept_handler
{
...
void operator()(
const boost::system::error_code& ec)
{
...
}
...
};
A lambda as a accept token:
acceptor.async_accept(...,
[](const boost::system::error_code& ec)
{
...
});
A non-static class member function adapted to a accept token using
`std::bind()`:
void my_class::accept_handler(
const boost::system::error_code& ec)
{
...
}
...
acceptor.async_accept(...,
std::bind(&my_class::accept_handler,
this, std::placeholders::_1));
A non-static class member function adapted to a accept token using
`boost::bind()`:
void my_class::accept_handler(
const boost::system::error_code& ec)
{
...
}
...
acceptor.async_accept(...,
boost::bind(&my_class::accept_handler,
this, boost::asio::placeholders::error));
Using [link boost_asio.reference.use_future use_future] as a accept token:
std::future<void> f = acceptor.async_accept(..., boost::asio::use_future);
...
try
{
f.get();
}
catch (const system_error& e)
{
...
}
Using [link boost_asio.reference.use_awaitable use_awaitable] as a accept token:
boost::asio::awaitable<void> my_coroutine()
{
try
{
...
co_await acceptor.async_accept(..., boost::asio::use_awaitable);
...
}
catch (const system_error& e)
{
...
}
}
[endsect]

View File

@@ -0,0 +1,25 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:AcceptableProtocol Acceptable protocol requirements]
A type `X` meets the `AcceptableProtocol` requirements if it satisfies the
requirements of [link boost_asio.reference.Protocol `Protocol`] as well as the
additional requirements listed below.
[table AcceptableProtocol requirements
[[expression] [return type] [assertion/note[br]pre/post-conditions]]
[
[`X::socket`]
[A type that satisfies the requirements of `Destructible` (C++Std
\[destructible\]) and `MoveConstructible` (C++Std \[moveconstructible\]),
and that is publicly and unambiguously derived from `basic_socket<X>`.]
[]
]
]
[endsect]

View File

@@ -0,0 +1,56 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:AsyncRandomAccessReadDevice Buffer-oriented asynchronous random-access
read device requirements]
In the table below, `a` denotes an asynchronous random access read device
object, `o` denotes an offset of type `boost::uint64_t`, `mb` denotes an object
satisfying [link boost_asio.reference.MutableBufferSequence mutable buffer sequence]
requirements, and `h` denotes an object satisfying [link
boost_asio.reference.ReadHandler read handler] requirements.
[table Buffer-oriented asynchronous random-access read device requirements
[[operation] [type] [semantics, pre/post-conditions]]
[
[`a.get_executor()`]
[A type satisfying the [link boost_asio.reference.Executor1 Executor requirements].]
[Returns the associated I/O executor.]
]
[
[`a.async_read_some_at(o, mb, h);`]
[`void`]
[
Initiates an asynchronous operation to read one or more bytes of data
from the device `a` at the offset `o`. The operation is performed via the
`io_service` object `a.get_io_service()` and behaves according to [link
boost_asio.reference.asynchronous_operations asynchronous operation]
requirements.[br]
[br]
The mutable buffer sequence `mb` specifies memory where the data should
be placed. The `async_read_some_at` operation shall always fill a buffer
in the sequence completely before proceeding to the next.[br]
[br]
The implementation shall maintain one or more copies of `mb` until such
time as the read operation no longer requires access to the memory
specified by the buffers in the sequence. The program must ensure the
memory is valid until:[br]
[br]
[mdash] the last copy of `mb` is destroyed, or[br]
[br]
[mdash] the handler for the asynchronous read operation is invoked,[br]
[br]
whichever comes first.[br]
[br]
If the total size of all buffers in the sequence `mb` is `0`, the
asynchronous read operation shall complete immediately and pass `0` as
the argument to the handler that specifies the number of bytes read.
]
]
]
[endsect]

View File

@@ -0,0 +1,57 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:AsyncRandomAccessWriteDevice Buffer-oriented asynchronous
random-access write device requirements]
In the table below, `a` denotes an asynchronous write stream object, `o`
denotes an offset of type `boost::uint64_t`, `cb` denotes an object satisfying
[link boost_asio.reference.ConstBufferSequence constant buffer sequence]
requirements, and `h` denotes an object satisfying [link
boost_asio.reference.WriteHandler write handler] requirements.
[table Buffer-oriented asynchronous random-access write device requirements
[[operation] [type] [semantics, pre/post-conditions]]
[
[`a.get_executor()`]
[A type satisfying the [link boost_asio.reference.Executor1 Executor requirements].]
[Returns the associated I/O executor.]
]
[
[`a.async_write_some_at(o, cb, h);`]
[`void`]
[
Initiates an asynchronous operation to write one or more bytes of data to
the device `a` at offset `o`. The operation is performed via the
`io_service` object `a.get_io_service()` and behaves according to [link
boost_asio.reference.asynchronous_operations asynchronous operation]
requirements.[br]
[br]
The constant buffer sequence `cb` specifies memory where the data to be
written is located. The `async_write_some_at` operation shall always
write a buffer in the sequence completely before proceeding to the
next.[br]
[br]
The implementation shall maintain one or more copies of `cb` until such
time as the write operation no longer requires access to the memory
specified by the buffers in the sequence. The program must ensure the
memory is valid until:[br]
[br]
[mdash] the last copy of `cb` is destroyed, or[br]
[br]
[mdash] the handler for the asynchronous write operation is invoked,[br]
[br]
whichever comes first.[br]
[br]
If the total size of all buffers in the sequence `cb` is `0`, the
asynchronous write operation shall complete immediately and pass `0` as
the argument to the handler that specifies the number of bytes written.
]
]
]
[endsect]

View File

@@ -0,0 +1,50 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:AsyncReadStream Buffer-oriented asynchronous read stream requirements]
A type `X` meets the `AsyncReadStream` requirements if it satisfies the
requirements listed below.
In the table below, `a` denotes a value of type `X`, `mb` denotes a (possibly
const) value satisfying the [link boost_asio.reference.MutableBufferSequence
`MutableBufferSequence`] requirements, and `t` is a completion token.
[table AsyncReadStream requirements
[[operation] [type] [semantics, pre/post-conditions]]
[
[`a.get_executor()`]
[A type satisfying the [link boost_asio.reference.Executor1 Executor requirements].]
[Returns the associated I/O executor.]
]
[
[`a.async_read_some(mb,t)`]
[
The return type is determined according to the requirements for an
[link boost_asio.reference.asynchronous_operations asynchronous operation].
]
[
Meets the requirements for a [link boost_asio.reference.read_write_operations
read operation] and an [link boost_asio.reference.asynchronous_operations
asynchronous operation] with completion signature `void(error_code ec,
size_t n)`.[br]
[br]
If `buffer_size(mb) > 0`, initiates an asynchronous operation to read one
or more bytes of data from the stream `a` into the buffer sequence `mb`.
If successful, `ec` is set such that `!ec` is `true`, and `n` is the
number of bytes read. If an error occurred, `ec` is set such that `!!ec`
is `true`, and `n` is 0. If all data has been read from the stream, and
the stream performed an orderly shutdown, `ec` is
`stream_errc::eof` and `n` is 0.[br]
[br]
If `buffer_size(mb) == 0`, the operation completes immediately. `ec` is
set such that `!ec` is `true`, and `n` is 0.
]
]
]
[endsect]

View File

@@ -0,0 +1,48 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:AsyncWriteStream Buffer-oriented asynchronous write stream requirements]
A type `X` meets the `AsyncWriteStream` requirements if it satisfies the
requirements listed below.
In the table below, `a` denotes a value of type `X`, `cb` denotes a (possibly
const) value satisfying the [link boost_asio.reference.ConstBufferSequence
`ConstBufferSequence`] requirements, and `t` is a completion token.
[table AsyncWriteStream requirements
[[operation] [type] [semantics, pre/post-conditions]]
[
[`a.get_executor()`]
[A type satisfying the [link boost_asio.reference.Executor1 Executor requirements].]
[Returns the associated I/O executor.]
]
[
[`a.async_write_some(cb,t)`]
[
The return type is determined according to the requirements for an
[link boost_asio.reference.asynchronous_operations asynchronous operation].
]
[
Meets the requirements for a [link boost_asio.reference.read_write_operations
write operation] and an [link boost_asio.reference.asynchronous_operations
asynchronous operation] with completion signature `void(error_code ec,
size_t n)`.[br]
[br]
If `buffer_size(cb) > 0`, initiates an asynchronous operation to write
one or more bytes of data to the stream `a` from the buffer sequence
`cb`. If successful, `ec` is set such that `!ec` is `true`, and `n` is
the number of bytes written. If an error occurred, `ec` is set such that
`!!ec` is `true`, and `n` is 0.[br]
[br]
If `buffer_size(cb) == 0`, the operation completes immediately. `ec` is
set such that `!ec` is `true`, and `n` is 0.
]
]
]
[endsect]

View File

@@ -0,0 +1,15 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:BufferedHandshakeHandler Buffered handshake handler requirements]
A buffered handshake handler must meet the requirements for a [link
boost_asio.reference.Handler handler]. A value `h` of a buffered handshake handler
class should work correctly in the expression `h(ec, s)`, where `ec` is an
lvalue of type `const error_code` and `s` is an lvalue of type `const size_t`.
[endsect]

View File

@@ -0,0 +1,111 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:BufferedHandshakeToken SSL buffered handshake token requirements]
A buffered_handshake token is a [link boost_asio.overview.model.completion_tokens
completion token] for completion signature `void(error_code, size_t)`.
[heading Examples]
A free function as a buffered_handshake token:
void buffered_handshake_handler(
const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
...
}
A buffered_handshake token function object:
struct buffered_handshake_handler
{
...
void operator()(
const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
...
}
...
};
A lambda as a buffered_handshake token:
ssl_stream.async_handshake(...,
[](const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
...
});
A non-static class member function adapted to a buffered_handshake token using
`std::bind()`:
void my_class::buffered_handshake_handler(
const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
...
}
...
ssl_stream.async_handshake(...,
std::bind(&my_class::buffered_handshake_handler,
this, std::placeholders::_1,
std::placeholders::_2));
A non-static class member function adapted to a buffered_handshake token using
`boost::bind()`:
void my_class::buffered_handshake_handler(
const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
...
}
...
ssl_stream.async_handshake(...,
boost::bind(&my_class::buffered_handshake_handler,
this, boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
Using [link boost_asio.reference.use_future use_future] as a buffered handshake token:
std::future<std::size_t> f =
ssl_stream.async_handshake(..., boost::asio::use_future);
...
try
{
std::size_t n = f.get();
...
}
catch (const system_error& e)
{
...
}
Using [link boost_asio.reference.use_awaitable use_awaitable] as a buffered handshake
token:
boost::asio::awaitable<void> my_coroutine()
{
try
{
...
std::size_t n =
co_await ssl_stream.async_handshake(
..., boost::asio::use_awaitable);
...
}
catch (const system_error& e)
{
...
}
}
[endsect]

View File

@@ -0,0 +1,49 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:CancellationHandler Cancellation handler requirements]
A value `h` of a cancellation handler class should work correctly in the
expression `h(t)`, where `t` is a value of type
`boost::asio::cancellation_type`.
[heading Examples]
A free function as a cancellation handler:
void cancellation_handler(
boost::asio::cancellation_type type)
{
...
}
slot.assign(cancellation_handler);
A cancellation handler function object:
struct cancellation_handler
{
...
void operator()(
boost::asio::cancellation_type type)
{
...
}
...
};
cancellation_handler& h = slot.assign(cancellation_handler{ ... });
A lambda as a cancellation handler:
auto& h = slot.assign(
[](boost::asio::cancellation_type type)
{
...
});
[endsect]

View File

@@ -0,0 +1,63 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:CancellationSlot Cancellation slot requirements]
A type `X` meets the `CancellationSlot` requirements if it satisfies the
requirements of `CopyConstructible` (C++Std [copyconstructible]) and
`Destructible` (C++Std [destructible]), as well as the additional requirements
listed below.
In the table below, `x1` and `x2` denote (possibly const) values of type `X`,
`mx1` denotes an xvalue of type `X`, `H` denotes a type that satisfies
`CancellationHandler`, `h` denotes an xvalue of type `H`, and `u0` to `uN`
denote identifiers.
[table CancellationSlot requirements
[[expression] [type] [assertion/note[br]pre/post-conditions]]
[
[`X u(x1);`]
[]
[Shall not exit via an exception.[br]
[br]
post: `u == x1`.]
]
[
[`X u(mx1);`]
[]
[Shall not exit via an exception.[br]
[br]
post: `u` equals the prior value of `mx1`.]
]
[
[`x1 == x2`]
[`bool`]
[ Returns `true` only if `x1` and `x2` can be interchanged with identical
effects.
[br]
`operator==` shall be reflexive, symmetric, and transitive, and shall not
exit via an exception.]
]
[
[`x1 != x2`]
[`bool`]
[Same as `!(x1 == x2)`.]
]
[
[`x1.assign(h)`]
[`H&`]
[]
]
[
[`x1.emplace<H>(u0, ..., uN)`]
[`H&`]
[Requires that `is_constructible<H, decltype(u0), ...,
decltype(u0)>::value` be true.]
]
]
[endsect]

View File

@@ -0,0 +1,42 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:CompletionCondition Completion condition requirements]
A ['completion condition] is a function object that is used with the algorithms
[link boost_asio.reference.read `read`], [link boost_asio.reference.async_read
`async_read`], [link boost_asio.reference.write `write`], and [link
boost_asio.reference.async_write `async_write`] to determine when the algorithm has
completed transferring data.
A type `X` meets the `CompletionCondition` requirements if it satisfies the
requirements of `Destructible` (C++Std [destructible]) and
`MoveConstructible` (C++Std [moveconstructible]), as well as the additional
requirements listed below.
In the table below, `x` denotes a value of type `X`, `ec` denotes a (possibly
const) value of type `error_code`, and `n` denotes a (possibly const) value of
type `size_t`.
[table CompletionCondition requirements
[[expression] [return type] [assertion/note[br]pre/post-condition]]
[
[`x(ec, n)`]
[`size_t`]
[
Let `n` be the total number of bytes transferred by the read or write
algorithm so far.[br]
[br]
Returns the maximum number of bytes to be transferred on the next
`read_some`, `async_read_some`, `write_some`, or `async_write_some`
operation performed by the algorithm. Returns `0` to indicate that the
algorithm is complete.
]
]
]
[endsect]

View File

@@ -0,0 +1,34 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:ConnectCondition Connect condition requirements]
A type `X` meets the `ConnectCondition` requirements if it satisfies the
requirements of `Destructible` (C++Std [destructible]) and
`CopyConstructible` (C++Std [copyconstructible]), as well as the additional
requirements listed below.
In the table below, `x` denotes a value of type `X`, `ec` denotes a (possibly
const) value of type `error_code`, and `ep` denotes a (possibly const) value of
some type satisfying the [link boost_asio.reference.Endpoint endpoint] requirements.
[table ConnectCondition requirements
[[expression] [return type] [assertion/note[br]pre/post-condition]]
[
[`x(ec, ep)`]
[`bool`]
[
Returns `true` to indicate that the `connect` or `async_connect`
algorithm should attempt a connection to the endpoint `ep`. Otherwise,
returns `false` to indicate that the algorithm should not attempt
connection to the endpoint `ep`, and should instead skip to the next
endpoint in the sequence.
]
]
]
[endsect]

View File

@@ -0,0 +1,15 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:ConnectHandler Connect handler requirements]
A connect handler must meet the requirements for a [link
boost_asio.reference.Handler handler]. A value `h` of a connect handler
class should work correctly in the expression `h(ec)`, where `ec` is an lvalue
of type `const error_code`.
[endsect]

View File

@@ -0,0 +1,99 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
/]
[section:ConnectToken Connect token requirements]
A connect token is a [link boost_asio.overview.model.completion_tokens completion token]
for completion signature `void(error_code)`.
[heading Examples]
A free function as a connect token:
void connect_handler(
const boost::system::error_code& ec)
{
...
}
A connect token function object:
struct connect_handler
{
...
void operator()(
const boost::system::error_code& ec)
{
...
}
...
};
A lambda as a connect token:
socket.async_connect(...,
[](const boost::system::error_code& ec)
{
...
});
A non-static class member function adapted to a connect token using
`std::bind()`:
void my_class::connect_handler(
const boost::system::error_code& ec)
{
...
}
...
socket.async_connect(...,
std::bind(&my_class::connect_handler,
this, std::placeholders::_1));
A non-static class member function adapted to a connect token using
`boost::bind()`:
void my_class::connect_handler(
const boost::system::error_code& ec)
{
...
}
...
socket.async_connect(...,
boost::bind(&my_class::connect_handler,
this, boost::asio::placeholders::error));
Using [link boost_asio.reference.use_future use_future] as a connect token:
std::future<void> f = socket.async_connect(..., boost::asio::use_future);
...
try
{
f.get();
}
catch (const system_error& e)
{
...
}
Using [link boost_asio.reference.use_awaitable use_awaitable] as a connect token:
boost::asio::awaitable<void> my_coroutine()
{
try
{
...
co_await socket.async_connect(..., boost::asio::use_awaitable);
...
}
catch (const system_error& e)
{
...
}
}
[endsect]

Some files were not shown because too many files have changed in this diff Show More