Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

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:

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:

New interface

Old interface

Notes

io_context

io_service

The name io_service is retained as a typedef.

dispatch

io_service::dispatch

The dispatch free function can be used to submit functions to any Executor or ExecutionContext.

post

io_service::post

The dispatch free function can be used to submit functions to any Executor or ExecutionContext.

defer

io_service::post when the asio_handler_is_continuation hook returns true

The defer free function can be used to submit functions to any Executor or ExecutionContext.

io_context::poll

io_service::poll overload that takes error_code&

The error_code overload is not required.

io_context::poll_one

io_service::poll_one overload that takes error_code&

The error_code overload is not required.

io_context::run

io_service::run overload that takes error_code&

The error_code overload is not required.

io_context::run_one

io_service::run_one overload that takes error_code&

The error_code overload is not required.

io_context::run_for, io_context::run_until, io_context::run_one_for, and io_context::run_one_until

These functions add the ability to run an io_context for a limited time.

io_context::restart

io_service::reset

io_context constructor concurrency_hint parameter is type int

io_context constructor concurrency_hint parameter is type std::size_t

The old constructor has not been retained as a deprecated overload.

execution_context, execution_context::service, and execution_context::id

io_service, io_service::service, and 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.

make_service

add_service

strand

io_service::strand

This template works with any valid executor, and is itself a valid executor.

executor_work_guard and make_work_guard

io_service::work

Work tracking is now covered by the Executor requirements. These templates work with any valid executor.

executor_binder and bind_executor

io_service::wrap and io_service::strand::wrap

These templates work with any valid executor.

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.

associated_executor and get_associated_executor

asio_handler_invoke

The handler invocation hook has been replaced by the new Executor requirements and the associated executor traits.

associated_allocator and get_associated_allocator

asio_handler_allocate and asio_handler_deallocate

The handler allocation hooks have been replaced by the standard Allocator requirements and the associated allocator traits.

const_buffer::data and mutable_buffer::data

buffer_cast

const_buffer::size and mutable_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

const_buffer

const_buffers_1

The ConstBufferSequence requirements have been modified such that const_buffer now satisfies them.

mutable_buffer

mutable_buffers_1

The MutableBufferSequence requirements have been modified such that mutable_buffer now satisfies them.

basic_socket::get_executor (and corresponding member for I/O objects such as timers, serial ports, etc.)

basic_io_object::get_io_service

Use get_executor().context() to obtain the associated io_context.

socket_base::max_listen_connections

socket_base::max_connections

socket_base::wait_type, basic_socket::wait, basic_socket::async_wait, basic_socket_acceptor::wait, and basic_socket_acceptor::async_wait

null_buffers

Operations for reactive I/O.

basic_socket_acceptor::accept returns a socket

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.

basic_socket_acceptor::async_accept passes socket to handler

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.

connect overloads that take a range

connect overloads that take a single iterator

The 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.

async_connect overloads that take a range

async_connect overloads that take a single iterator

The 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.

basic_socket_streambuf::duration

basic_socket_streambuf::duration_type

basic_socket_streambuf::time_point

basic_socket_streambuf::time_type

basic_socket_streambuf::expiry

basic_socket_streambuf::expires_at and basic_socket_streambuf::expires_from_now getters

basic_socket_streambuf::expires_after

basic_socket_streambuf::expires_from_now setter

basic_socket_streambuf::error

basic_socket_streambuf::puberror

basic_socket_iostream::duration

basic_socket_iostream::duration_type

basic_socket_iostream::time_point

basic_socket_iostream::time_type

basic_socket_iostream::expiry

basic_socket_iostream::expires_at and basic_socket_iostream::expires_from_now getters

basic_socket_iostream::expires_after

basic_socket_iostream::expires_from_now setter

basic_waitable_timer::cancel

basic_waitable_timer::cancel overload that takes error_code&

The error_code overload is not required.

basic_waitable_timer::cancel_one

basic_waitable_timer::cancel_one overload that takes error_code&

The error_code overload is not required.

basic_waitable_timer::expires_at setter

basic_waitable_timer::expires_at setter that takes error_code&

The error_code overload is not required.

basic_waitable_timer::expiry

basic_waitable_timer::expires_at and basic_waitable_timer::expires_from_now getters

basic_waitable_timer::expires_after

basic_waitable_timer::expires_from_now setter

ip::make_address

ip::address::from_string

ip::make_address_v4

ip::address_v4::from_string and ip::address_v6::to_v4

ip::make_address_v6

ip::address_v6::from_string and ip::address_v6::v4_mapped

ip::address::to_string

ip::address::to_string that takes error_code&

The error_code overload is not required.

ip::address_v4::to_string

ip::address_v4::to_string that takes error_code&

The error_code overload is not required.

ip::address_v6::to_string

ip::address_v6::to_string that takes error_code&

The error_code overload is not required.

No replacement

ip::address_v6::is_v4_compatible and ip::address_v6::v4_compatible

ip::network_v4

ip::address_v4::broadcast, ip::address_v4::is_class_a, ip::address_v4::is_class_b, ip::address_v4::is_class_c, and ip::address_v4::netmask

The network_v4 class adds the ability to manipulate IPv4 network addresses using CIDR notation.

ip::network_v6

The network_v6 class adds the ability to manipulate IPv6 network addresses using CIDR notation.

ip::address_v4_iterator and 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.

ip::address_v6_iterator and 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.

ip::basic_resolver::results_type

ip::basic_resolver::iterator

Resolvers now produce ranges rather than single iterators.

ip::basic_resolver::resolve overloads taking hostname and service as arguments

ip::basic_resolver::resolve overloads taking a ip::basic_resolver::query

ip::basic_resolver::resolve returns a range

ip::basic_resolver::resolve returns a single iterator

ip::basic_resolver::async_resolve overloads taking hostname and service as arguments

ip::basic_resolver::async_resolve overloads taking a ip::basic_resolver::query

ip::basic_resolver::async_resolve calls the handler with a range

ip::basic_resolver::async_resolve calls the handler with a single iterator


PrevUpHomeNext