PD ISO - IEC TS 19216-2018 Programming Languages
PD ISO - IEC TS 19216-2018 Programming Languages
National foreword
This Published Document is the UK implementation of ISO/IEC
TS 19216:2018.
The UK participation in its preparation was entrusted to Technical
Committee IST/5, Programming languages, their environments and
system software interfaces.
A list of organizations represented on this committee can be obtained on
request to its secretary.
This publication does not purport to include all the necessary provisions
of a contract. Users are responsible for its correct application.
© The British Standards Institution 2018
Published by BSI Standards Limited 2018
ISBN 978 0 580 97077 1
ICS 35.060
Compliance with a British Standard cannot confer immunity from
legal obligations.
This Published Document was published under the authority of the
Standards Policy and Strategy Committee on 31 May 2018.
First edition
2018-04
Reference number
ISO/IEC TS 19216:2018(E)
© ISO/IEC 2018
PD ISO/IEC/TS 19216:2018
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
Contents
Foreword vi
1 Scope 1
2 Normative references 2
4 General Principles 4
4.1 Conformance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.2 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
9 Error reporting 9
9.1 Synchronous operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
9.2 Asynchronous operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
9.3 Error conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
9.4 Suppression of signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
10 Library summary 11
11 Convenience header 13
11.1 Header <experimental/net> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
12 Forward declarations 14
12.1 Header <experimental/netfwd> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
13 Asynchronous model 16
13.1 Header <experimental/executor> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
13.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
13.3 Class template async_result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
13.4 Class template async_completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
13.5 Class template associated_allocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
13.6 Function get_associated_allocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
13.7 Class execution_context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
13.8 Class execution_context::service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
13.9 Class template is_executor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
13.10 Executor argument tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
13.11 uses_executor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
ISO/IEC TS 19216:2018(E)
15 Timers 67
15.1 Header <experimental/timer> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
15.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
15.3 Class template wait_traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
15.4 Class template basic_waitable_timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
16 Buffers 73
16.1 Header <experimental/buffer> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
16.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
16.3 Error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
16.4 Class mutable_buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
16.5 Class const_buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
16.6 Buffer type traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
16.7 Buffer sequence access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
16.8 Function buffer_size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
16.9 Function buffer_copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
16.10 Buffer arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
16.11 Buffer creation functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
16.12 Class template dynamic_vector_buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
16.13 Class template dynamic_string_buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
16.14 Dynamic buffer creation functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
17 Buffer-oriented streams 92
17.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
17.2 Class transfer_all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
17.3 Class transfer_at_least . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
17.4 Class transfer_exactly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
17.5 Synchronous read operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
17.6 Asynchronous read operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
ISO/IEC TS 19216:2018(E)
18 Sockets 104
18.1 Header <experimental/socket> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
18.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
18.3 Error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
18.4 Class socket_base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
18.5 Socket options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
18.6 Class template basic_socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
18.7 Class template basic_datagram_socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
18.8 Class template basic_stream_socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
18.9 Class template basic_socket_acceptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Index 219
ISO/IEC TS 19216:2018(E)
Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical
Commission) form the specialized system for worldwide standardization. National bodies that are members
of ISO or IEC participate in the development of International Standards through technical committees
established by the respective organization to deal with particular fields of technical activity. ISO and IEC
technical committees collaborate in fields of mutual interest. Other international organizations, governmental
and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information
technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1.
The procedures used to develop this document and those intended for its further maintenance are described
in the ISO/IEC Directives, Part 1. In particular the different approval criteria needed for the different types
of ISO documents should be noted. This document was drafted in accordance with the editorial rules of the
ISO/IEC Directives, Part 2 (see www.iso.org/directives).
Attention is drawn to the possibility that some of the elements of this document may be the subject of patent
rights. ISO shall not be held responsible for identifying any or all such patent rights. Details of any patent
rights identified during the development of the document will be in the Introduction and/or on the ISO list
of patent declarations received (see www.iso.org/patents).
Any trade name used in this document is information given for the convenience of users and does not
constitute an endorsement.
For an explanation on the voluntary nature of standards, the meaning of ISO specific terms and ex-
pressions related to conformity assessment, as well as information about ISO’s adherence to the World
Trade Organization (WTO) principles in the Technical Barriers to Trade (TBT) see the following URL:
www.iso.org/iso/foreword.html.
This document was prepared by Technical Committee ISO/IEC JTC 1, Information technology, Subcommittee
SC 22, Programming languages, their environments and system software interfaces.
ISO/IEC TS 19216:2018(E)
1 Scope [scope]
1 This document describes extensions to the C++ Standard Library. This document specifies requirements for
implementations of an interface that computer programs written in the C++ programming language may use
to perform operations related to networking, such as operations involving sockets, timers, buffer management,
host name resolution and internet protocols. This document is applicable to information technology systems
that can perform network operations, such as those with operating systems that conform to the POSIX
interface. This document is applicable only to vendors who wish to provide the interface it describes.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
3 Terms that are used only in a small portion of this document are defined where they are used and italicized
where they are defined.
3.1 [defs.host.byte.order]
host byte order
the arrangement of bytes in any integer type when using a specific machine architecture
[SOURCE: ISO/IEC 9945:2009, 3.193]
3.2 [defs.net.byte.order]
network byte order
the way of representing any integer type such that, when transmitted over a network via a network endpoint,
the int type is transmitted as an appropriate number of octets with the most significant octet first, followed
by any other octets in descending order of significance
[SOURCE: ISO/IEC 9945:2009, 3.237]
3.3 [defs.sync.op]
synchronous operation
operation where control is not returned until the operation completes
3.4 [defs.async.op]
asynchronous operation
operation where control is returned immediately without waiting for the operation to complete
[ Note 1 to entry: Multiple asynchronous operations may be executed concurrently. — end note ]
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
2 Unless otherwise specified, references to other entities described in this document are assumed to be qualified
with std::experimental::net::v1::, references to entities described in the C++ standard are assumed to
be qualified with std::, and references to entities described in C++ Extensions for Library Fundamentals are
assumed to be qualified with std::experimental::fundamentals_v2::.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
(1.1) — Uses where system errors are truly exceptional and indicate a serious failure. Throwing an exception is
the most appropriate response.
(1.2) — Uses where system errors are routine and do not necessarily represent failure. Returning an error code
is the most appropriate response. This allows application specific error handling, including simply
ignoring the error.
— end note ]
2 Functions not having an argument of type error_code& report errors as follows, unless otherwise specified:
(2.1) — When a call by the implementation to an operating system or other underlying API results in an error
that prevents the function from meeting its specifications, the function exits via an exception of a type
that would match a handler of type system_error.
(2.2) — Destructors throw nothing.
3 Functions having an argument of type error_code& report errors as follows, unless otherwise specified:
(3.1) — If a call by the implementation to an operating system or other underlying API results in an error
that prevents the function from meeting its specifications, the error_code& argument ec is set as
appropriate for the specific error. Otherwise, the ec argument is set such that !ec is true.
4 Where a function is specified as two overloads, with and without an argument of type error_code&:
R f (A1 a1, A2 a2, ..., AN aN);
R f (A1 a1, A2 a2, ..., AN aN, error_code& ec);
5 then, when R is non-void, the effects of the first overload are as if:
error_code ec;
R r(f (a1, a2, ..., aN, ec));
if (ec) throw system_error(ec, S);
return r;
6 otherwise, when R is void, the effects of the first overload are as if:
error_code ec;
f (a1, a2, ..., aN, ec);
if (ec) throw system_error(ec, S);
7 except that the type thrown may differ as specified above. S is an ntbs indicating where the exception was
thrown. [ Note: A possible value for S is __func__. — end note ]
8 For both overloads, failure to allocate storage is reported by throwing an exception as described in the C++
standard (C++ 2014, 17.6.5.12).
9 In this document, when a type requirement is specified using two function call expressions f, with and without
an argument ec of type error_code:
ISO/IEC TS 19216:2018(E)
then the effects of the first call expression of f shall be as described for the first overload above.
ISO/IEC TS 19216:2018(E)
Clause Header(s)
Convenience header (11) <experimental/net>
Forward declarations (12) <experimental/netfwd>
Asynchronous model (13) <experimental/executor>
Basic I/O services (14) <experimental/io_context>
Timers (15) <experimental/timer>
Buffers (16) <experimental/buffer>
Buffer-oriented streams (17)
Sockets (18) <experimental/socket>
Socket iostreams (19)
Socket algorithms (20)
Internet protocol (21) <experimental/internet>
1 Throughout this document, the names of the template parameters are used to express type requirements, as
listed in Table 3.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
1 [ Note: This header is provided as a convenience for programs so that they may access all networking facilities
via a single, self-contained #include. — end note ]
ISO/IEC TS 19216:2018(E)
class execution_context;
template<class T, class Executor>
class executor_binder;
template<class Executor>
class executor_work_guard;
class system_executor;
class executor;
template<class Executor>
class strand;
class io_context;
template<class Protocol>
class basic_socket;
template<class Protocol>
class basic_datagram_socket;
template<class Protocol>
class basic_stream_socket;
template<class Protocol>
class basic_socket_acceptor;
template<class Protocol, class Clock = chrono::steady_clock,
class WaitTraits = wait_traits<Clock>>
class basic_socket_streambuf;
template<class Protocol, class Clock = chrono::steady_clock,
class WaitTraits = wait_traits<Clock>>
class basic_socket_iostream;
namespace ip {
class address;
class address_v4;
class address_v6;
template<class Address>
class basic_address_iterator;
using address_v4_iterator = basic_address_iterator<address_v4>;
using address_v6_iterator = basic_address_iterator<address_v6>;
ISO/IEC TS 19216:2018(E)
template<class Address>
class basic_address_range;
using address_v4_range = basic_address_range<address_v4>;
using address_v6_range = basic_address_range<address_v6>;
class network_v4;
class network_v6;
template<class InternetProtocol>
class basic_endpoint;
template<class InternetProtocol>
class basic_resolver_entry;
template<class InternetProtocol>
class basic_resolver_results;
template<class InternetProtocol>
class basic_resolver;
class tcp;
class udp;
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
1 Default template arguments are described as appearing both in <netfwd> and in the synopsis of other headers
but it is well-formed to include both <netfwd> and one or more of the other headers. [ Note: It is the
implementation’s responsibility to implement headers so that including <netfwd> and other headers does not
violate the rules about multiple occurrences of default arguments. — end note ]
ISO/IEC TS 19216:2018(E)
// 13.6, get_associated_allocator:
template<class T>
associated_allocator_t<T> get_associated_allocator(const T& t) noexcept;
template<class T, class ProtoAllocator>
associated_allocator_t<T, ProtoAllocator>
get_associated_allocator(const T& t, const ProtoAllocator& a) noexcept;
class execution_context;
class service_already_exists;
template<class T>
constexpr bool is_executor_v = is_executor<T>::value;
struct executor_arg_t { };
constexpr executor_arg_t executor_arg = executor_arg_t();
ISO/IEC TS 19216:2018(E)
// 13.13, get_associated_executor:
template<class T>
associated_executor_t<T> get_associated_executor(const T& t) noexcept;
template<class T, class Executor>
associated_executor_t<T, Executor>
get_associated_executor(const T& t, const Executor& ex) noexcept;
template<class T, class ExecutionContext>
associated_executor_t<T, typename ExecutionContext::executor_type>
get_associated_executor(const T& t, ExecutionContext& ctx) noexcept;
// 13.15, bind_executor:
template<class Executor>
class executor_work_guard;
// 13.17, make_work_guard:
template<class Executor>
executor_work_guard<Executor>
make_work_guard(const Executor& ex);
template<class ExecutionContext>
executor_work_guard<typename ExecutionContext::executor_type>
make_work_guard(ExecutionContext& ctx);
template<class T>
ISO/IEC TS 19216:2018(E)
executor_work_guard<associated_executor_t<T>>
make_work_guard(const T& t);
template<class T, class U>
auto make_work_guard(const T& t, U&& u)
-> decltype(make_work_guard(get_associated_executor(t, forward<U>(u))));
class system_executor;
class system_context;
class bad_executor;
class executor;
// 13.22, dispatch:
template<class CompletionToken>
DEDUCED dispatch(CompletionToken&& token);
template<class Executor, class CompletionToken>
DEDUCED dispatch(const Executor& ex, CompletionToken&& token);
template<class ExecutionContext, class CompletionToken>
DEDUCED dispatch(ExecutionContext& ctx, CompletionToken&& token);
// 13.23, post:
template<class CompletionToken>
DEDUCED post(CompletionToken&& token);
template<class Executor, class CompletionToken>
DEDUCED post(const Executor& ex, CompletionToken&& token);
template<class ExecutionContext, class CompletionToken>
DEDUCED post(ExecutionContext& ctx, CompletionToken&& token);
// 13.24, defer:
template<class CompletionToken>
DEDUCED defer(CompletionToken&& token);
template<class Executor, class CompletionToken>
DEDUCED defer(const Executor& ex, CompletionToken&& token);
template<class ExecutionContext, class CompletionToken>
DEDUCED defer(ExecutionContext& ctx, CompletionToken&& token);
template<class Executor>
class strand;
template<class Executor>
bool operator==(const strand<Executor>& a, const strand<Executor>& b);
ISO/IEC TS 19216:2018(E)
template<class Executor>
bool operator!=(const strand<Executor>& a, const strand<Executor>& b);
} // inline namespace v1
} // namespace net
} // namespace experimental
template<class Allocator>
struct uses_allocator<experimental::net::v1::executor, Allocator>
: true_type {};
} // namespace std
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
— end example ]
5 A service’s shutdown member function shall destroy all copies of function objects that are held by the service.
ISO/IEC TS 19216:2018(E)
an associated type A meeting the type requirements R may be computed, and an associated object a of type
A may be obtained.
2 An associator shall be a class template that takes two template type arguments. The first template argument
is the source type S. The second template argument is the candidate type C. The second template argument
shall be defaulted to some default candidate type D that satisfies the type requirements R.
3 An associator shall additionally satisfy the requirements in Table 6. In this table, X is a class template that
meets the associator requirements, S is the source type, s is a value of type S or const S, C is the candidate
type, c is a (possibly const) value of type C, D is the default candidate type, and d is a (possibly const) value
of type D that is the default candidate object.
4 The associator’s primary template shall be defined. A program may partially specialize the associator class
template for some user-defined type S.
5 Finally, the associator shall provide the following type alias and function template in the enclosing namespace:
template<class S, class C = D> using X _t = typename X <S, C>::type;
where X is replaced with the name of the associator class template. [ Note: This function template is provided
as a convenience, to automatically deduce the source and candidate types. — end note ]
ISO/IEC TS 19216:2018(E)
(2.5) — Event 3: The completion handler is called with the result of the asynchronous operation.
3 In this document, all functions with the prefix async_ are initiating functions.
return result.get();
}
ISO/IEC TS 19216:2018(E)
3 For convenience, initiating functions may be implemented using the async_completion template:
template<class CompletionToken>
auto async_xyz(T1 t1, T2 t2, CompletionToken&& token)
{
async_completion<CompletionToken, void(R1, R2)> init(token);
return init.result.get();
}
— end example ]
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
explicit async_result(completion_handler_type&) {}
async_result(const async_result&) = delete;
async_result& operator=(const async_result&) = delete;
return_type get() {}
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
2 The template parameter CompletionToken shall be an object type. The template parameter Signature
shall be a call signature (C++ 2014, 20.9.1).
3 Specializations of async_result shall satisfy the Destructible requirements (C++ 2014, 17.6.3.1) in addition
to the requirements in Table 7. In this table, R is a specialization of async_result; r is a modifiable lvalue
of type R; and h is a modifiable lvalue of type R::completion_handler_type.
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
2 The template parameter Signature shall be a call signature (C++ 2014, 20.9.1).
explicit async_completion(CompletionToken& t);
3 Effects: If CompletionToken and completion_handler_type are the same type, binds completion_-
handler to t; otherwise, initializes completion_handler with std::forward<CompletionToken>(t).
Initializes result with completion_handler.
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
1 Type: T::allocator_type if the qualified-id T::allocator_type is valid and denotes a type (C++
2014, 14.8.2). Otherwise ProtoAllocator.
class execution_context
{
public:
class service;
execution_context();
execution_context(const execution_context&) = delete;
execution_context& operator=(const execution_context&) = delete;
virtual ~execution_context();
protected:
// service access:
template<class Service> typename Service::key_type&
use_service(execution_context& ctx);
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Access to the services of an execution_context is via three function templates, use_service, make_service
and has_service.
3 In a call to use_service<Service>, the type argument chooses a service, identified by Service::key_type,
from a set of services in an execution_context. If the service is not present in the execution_context,
an object of type Service is created and added to the execution_context. A program can check if an
execution_context implements a particular service with the function template has_service<Service>.
4 Service objects may be explicitly added to an execution_context using the function template make_-
service<Service>. If the service is already present, make_service exits via an exception of type service_-
already_exists.
5 Once a service reference is obtained from an execution_context object by calling use_service, that
reference remains usable until a call to destroy().
6 If a call to a specialization of use_service or make_service recursively calls another specialization of
use_service or make_service which would choose the same service (identified by key_type) from the same
execution_context, then the behavior is undefined. [ Note: Nested calls to specializations for different
service types are well-defined. — end note ]
ISO/IEC TS 19216:2018(E)
class execution_context::service
{
protected:
// construct / copy / destroy:
// service observers:
ISO/IEC TS 19216:2018(E)
private:
// service operations:
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
struct executor_arg_t { };
constexpr executor_arg_t executor_arg = executor_arg_t();
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
1 The executor_arg_t struct is an empty structure type used as a unique type to disambiguate constructor and
function overloading. Specifically, types may have constructors with executor_arg_t as the first argument,
immediately followed by an argument of a type that satisfies the Executor requirements (13.2.2).
13.11 uses_executor [async.uses.executor]
13.11.1 uses_executor trait [async.uses.executor.trait]
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
1 Remark: Detects whether T has a nested executor_type that is convertible from Executor. Meets the
BinaryTypeTrait requirements (C++ 2014, 20.10.1). The implementation provides a definition that is
derived from true_type if a type T::executor_type exists and is_convertible<Executor, T::executor_-
type>::value != false, otherwise it is derived from false_type. A program may specialize this template
to derive from true_type for a user-defined type T that does not have a nested executor_type but nonetheless
can be constructed with an executor if the first argument of a constructor has type executor_arg_t and the
second argument has type Executor.
13.11.2 uses-executor construction [async.uses.executor.cons]
1 Uses-executor construction with executor Executor refers to the construction of an object obj of type T,
using constructor arguments v1, v2, ..., vN of types V1, V2, ..., VN, respectively, and an executor ex
of type Executor, according to the following rules:
(1.1) — if uses_executor_v<T, Executor> is true and is_constructible<T, executor_arg_t, Executor,
V1, V2, ..., VN>::value is true, then obj is initialized as obj(executor_arg, ex, v1, v2, ...,
vN);
(1.2) — otherwise, obj is initialized as obj(v1, v2, ..., vN).
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
using target_type = T;
using executor_type = Executor;
~executor_binder();
// 13.14.2, executor binder access:
template<class... Args>
result_of_t<T&(Args&&...)> operator()(Args&&... args);
template<class... Args>
result_of_t<const T&(Args&&...)> operator()(Args&&... args) const;
private:
Executor ex_; // exposition only
T target_; // exposition only
};
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
return_type get();
private:
async_result<T, Signature> target_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
return_type get();
2 Returns: target_.get().
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
executor_binder<decay_t<T>, Executor>
bind_executor(const Executor& ex, T&& t);
1 Returns: executor_binder<decay_t<T>, Executor>(forward<T>(t), ex).
2 Remarks: This function shall not participate in overload resolution unless is_executor_v<Executor>
is true.
template<class Executor>
class executor_work_guard
{
public:
// types:
~executor_work_guard();
// executor work guard observers:
private:
Executor ex_; // exposition only
bool owns_; // exposition only
};
} // inline namespace v1
} // namespace net
ISO/IEC TS 19216:2018(E)
} // namespace experimental
} // namespace std
~executor_work_guard();
6 Effects: If owns_ is true, performs ex_.on_work_finished().
template<class ExecutionContext>
executor_work_guard<typename ExecutionContext::executor_type>
make_work_guard(ExecutionContext& ctx);
3 Returns: make_work_guard(ctx.get_executor()).
4 Remarks: This function shall not participate in overload resolution unless is_convertible<Execution-
Context&, execution_context&>::value is true.
template<class T>
executor_work_guard<associated_executor_t<T>>
make_work_guard(const T& t);
ISO/IEC TS 19216:2018(E)
5 Returns: make_work_guard(get_associated_executor(t)).
6 Remarks: This function shall not participate in overload resolution unless is_executor_v<T> is false
and is_convertible<T&, execution_context&>::value is false.
class system_executor
{
public:
// constructors:
system_executor() {}
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Class system_executor satisfies the Destructible (C++ 2014, 17.6.3.1), DefaultConstructible (C++ 2014,
17.6.3.1), and Executor (13.2.2) type requirements.
3 To satisfy the Executor requirements for the post and defer member functions, the system executor may
create thread objects to run the submitted function objects. These thread objects are collectively referred
to as system threads.
ISO/IEC TS 19216:2018(E)
system_context() = delete;
system_context(const system_context&) = delete;
system_context& operator=(const system_context&) = delete;
~system_context();
// system_context operations:
ISO/IEC TS 19216:2018(E)
void stop();
bool stopped() const noexcept;
void join();
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
~system_context();
4 Effects: Performs stop() followed by join().
void stop();
6 Effects: Signals all system threads to exit as soon as possible. If a system thread is currently executing
a function object, the thread will exit only after completion of that function object. Returns without
waiting for the system threads to complete.
7 Postconditions: stopped() == true.
void join();
9 Effects: Blocks the calling thread (C++ 2014, 17.3.2) until all system threads have completed.
10 Synchronization: The completion of each system thread synchronizes with (C++ 2014, 1.10) the
corresponding successful join() return.
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
bad_executor() noexcept;
2 Effects: constructs a bad_executor object.
3 Postconditions: what() returns an implementation-defined ntbs.
class executor
{
public:
// 13.21.1, construct / copy / destroy:
executor() noexcept;
executor(nullptr_t) noexcept;
executor(const executor& e) noexcept;
executor(executor&& e) noexcept;
template<class Executor> executor(Executor e);
template<class Executor, class ProtoAllocator>
executor(allocator_arg_t, const ProtoAllocator& a, Executor e);
~executor();
// 13.21.4, executor modifiers:
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
template<class Allocator>
struct uses_allocator<experimental::net::v1::executor, Allocator>
: true_type {};
} // namespace std
2 Class executor meets the requirements of Executor (13.2.2), DefaultConstructible (C++ 2014, 17.6.3.1),
and CopyAssignable (C++ 2014, 17.6.3.1).
3 [ Note: To meet the noexcept requirements for executor copy constructors and move constructors, implemen-
tations can share a target between two or more executor objects. — end note ]
4 The target is the executor object that is held by the wrapper.
executor(nullptr_t) noexcept;
2 Postconditions: !*this.
ISO/IEC TS 19216:2018(E)
executor(executor&& e) noexcept;
4 Effects: If !e, *this has no target; otherwise, moves e.target() or move-constructs the target of e
into the target of *this, leaving e in a valid state with an unspecified value.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
template<class Executor>
class strand
{
public:
// types:
strand();
explicit strand(Executor ex);
template<class ProtoAllocator>
strand(allocator_arg_t, const ProtoAllocator& alloc, Executor ex);
strand(const strand& other) noexcept;
strand(strand&& other) noexcept;
template<class OtherExecutor> strand(const strand<OtherExecutor>& other) noexcept;
template<class OtherExecutor> strand(strand<OtherExecutor>&& other) noexcept;
ISO/IEC TS 19216:2018(E)
~strand();
// 13.25.4, strand operations:
private:
Executor inner_ex_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
6 All member functions, except for the assignment operators and the destructor, do not introduce data races
on *this, including its ordered, non-concurrent state. Additionally, constructors and assignment operators
do not introduce data races on lvalue arguments.
7 If any function f executed by the strand throws an exception, the subsequent strand state is as if f had
exited without throwing an exception.
template<class ProtoAllocator>
strand(allocator_arg_t, const ProtoAllocator& a, Executor ex);
4 Effects: Constructs an object of class strand<Executor> that represents a unique ordered, non-
concurrent state. Initializes inner_ex_ as inner_ex_(ex). A copy of the allocator argument a is used
to allocate memory, if necessary, for the internal data structures of the constructed strand object.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
2 Returns: true if the current thread of execution is running a function that was submitted to the strand,
or to any other strand object s such that s == *this, using dispatch, post or defer; otherwise false.
[ Note: That is, the current thread of execution’s call chain includes a function that was submitted to
the strand. — end note ]
ISO/IEC TS 19216:2018(E)
{
public:
// use_future_t types:
using allocator_type = ProtoAllocator;
// use_future_t members:
constexpr use_future_t() noexcept(noexcept(allocator_type()));
explicit use_future_t(const allocator_type& a) noexcept;
template<class OtherProtoAllocator> use_future_t<OtherProtoAllocator>
rebind(const OtherProtoAllocator& a) const noexcept;
allocator_type get_allocator() const noexcept;
template <class F> unspecified operator()(F&& f) const;
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
7 The implementation provides a partial specialization template <class Result, class... Args>
async_result<T, Result(Args...)> such that:
(7.1) — the nested type completion_handler_type is a type H;
(7.2) — the nested type return_type is future<result_of_t<FD(decay_t<Args>...)>>; and
(7.3) — when an object r1 of type async_result<T, Result(Args...)> is constructed from h, the
expression r1.get() returns a future with the same shared state as h.
8 For any executor type E, the associated object for the associator associated_executor<H, E> is an
executor where, for function objects executed using the executor’s dispatch(), post() or defer()
functions, any exception thrown is caught by a function object and stored in the associated shared
state.
return_type get();
};
ISO/IEC TS 19216:2018(E)
Table 10 — async_result<use_future_t<ProtoAllocator>,
Result(Args...)> semantics
ISO/IEC TS 19216:2018(E)
return_type get();
private:
return_type future_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
return_type get();
2 Returns: std::move(future_).
ISO/IEC TS 19216:2018(E)
class io_context;
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
class executor_type;
using count_type = implementation-defined ;
io_context();
explicit io_context(int concurrency_hint);
io_context(const io_context&) = delete;
io_context& operator=(const io_context&) = delete;
// io_context operations:
count_type run();
template<class Rep, class Period>
count_type run_for(const chrono::duration<Rep, Period>& rel_time);
template<class Clock, class Duration>
count_type run_until(const chrono::time_point<Clock, Duration>& abs_time);
count_type run_one();
template<class Rep, class Period>
count_type run_one_for(const chrono::duration<Rep, Period>& rel_time);
template<class Clock, class Duration>
ISO/IEC TS 19216:2018(E)
count_type poll();
count_type poll_one();
void stop();
void restart();
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
count_type run();
4 Effects: Equivalent to:
count_type n = 0;
while (run_one())
if (n != numeric_limits<count_type>::max())
++n;
5 Returns: n.
6 [ Note: Calling run from a thread that is currently calling a run function can introduce the potential
for deadlock. It is the caller’s responsibility to avoid such deadlocks. — end note ]
9 Returns: n.
count_type run_one();
10 Effects: If the io_context object has no outstanding work, performs stop(). Otherwise, blocks while
the io_context has outstanding work, or until the io_context is stopped, or until one function object
has been executed.
11 If an executed function object throws an exception, the exception propagates to the caller of run_one().
The io_context state is as if the function object had returned normally.
12 Returns: 1 if a function object was executed, otherwise 0.
13 Remarks: This function may invoke additional function objects through nested calls to the io_context
executor’s dispatch member function. These do not count towards the return value.
14 [ Note: Calling run_one from a thread that is currently calling a run function can introduce the potential
for deadlock. It is the caller’s responsibility to avoid such deadlocks. — end note ]
ISO/IEC TS 19216:2018(E)
16 Effects: If the io_context object has no outstanding work, performs stop(). Otherwise, blocks while
the io_context has outstanding work, or until the expiration of the absolute timeout (C++ 2014, 30.2.4)
specified by abs_time, or until the io_context is stopped, or until one function object has been
executed.
17 If an executed function object throws an exception, the exception propagates to the caller of run_one().
The io_context state is as if the function object had returned normally.
18 Returns: 1 if a function object was executed, otherwise 0.
19 Remarks: This function may invoke additional function objects through nested calls to the io_context
executor’s dispatch member function. These do not count towards the return value.
count_type poll();
20 Effects: Equivalent to:
count_type n = 0;
while (poll_one())
if (n != numeric_limits<count_type>::max())
++n;
21 Returns: n.
count_type poll_one();
22 Effects: If the io_context object has no outstanding work, performs stop(). Otherwise, if there is a
function object ready for immediate execution, executes it.
23 If an executed function object throws an exception, the exception propagates to the caller of poll_one().
The io_context state is as if the function object had returned normally.
24 Returns: 1 if a function object was invoked, otherwise 0.
25 Remarks: This function may invoke additional function objects through nested calls to the io_context
executor’s dispatch member function. These do not count towards the return value.
void stop();
26 Effects: Stops the io_context. Concurrent calls to any run function will end as soon as possible. If a
call to a run function is currently executing a function object, the call will end only after completion of
that function object. The call to stop() returns without waiting for concurrent calls to run functions
to complete.
27 Postconditions: stopped() == true.
28 [ Note: When stopped() == true, subsequent calls to a run function will exit immediately with a
return value of 0, without executing any function objects. An io_context remains in the stopped state
until a call to restart(). — end note ]
void restart();
30 Postconditions: stopped() == false.
ISO/IEC TS 19216:2018(E)
class io_context::executor_type
{
public:
// 14.3.1, construct / copy / destroy:
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
15 Timers [timer]
1 This clause defines components for performing timer operations.
2 [ Example: Performing a synchronous wait operation on a timer:
io_context c;
steady_timer t(c);
t.expires_after(seconds(5));
t.wait();
— end example ]
3 [ Example: Performing an asynchronous wait operation on a timer:
void handler(error_code ec) { ... }
...
io_context c;
steady_timer t(c);
t.expires_after(seconds(5));
t.async_wait(handler);
c.run();
— end example ]
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
— end note ]
2 For a type Clock meeting the Clock requirements (C++ 2014, 20.12.3), a type X meets the WaitTraits
requirements if it satisfies the requirements listed below.
3 In Table 11, t denotes a (possibly const) value of type Clock::time_point; and d denotes a (possibly const)
value of type Clock::duration.
template<class Clock>
struct wait_traits
{
static typename Clock::duration to_wait_duration(
const typename Clock::duration& d);
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
1 Class template wait_traits satisfies the WaitTraits (15.2.1) type requirements. Template argument Clock
is a type meeting the Clock requirements (C++ 2014, 20.12.3).
ISO/IEC TS 19216:2018(E)
~basic_waitable_timer();
basic_waitable_timer& operator=(const basic_waitable_timer&) = delete;
basic_waitable_timer& operator=(basic_waitable_timer&& rhs);
size_t cancel();
size_t cancel_one();
void wait();
void wait(error_code& ec);
ISO/IEC TS 19216:2018(E)
template<class CompletionToken>
DEDUCED async_wait(CompletionToken&& token);
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
1 Instances of class template basic_waitable_timer meet the requirements of Destructible (C++ 2014,
17.6.3.1), MoveConstructible (C++ 2014, 17.6.3.1), and MoveAssignable (C++ 2014, 17.6.3.1).
15.4.1 basic_waitable_timer constructors [timer.waitable.cons]
explicit basic_waitable_timer(io_context& ctx);
1 Effects: Equivalent to basic_waitable_timer(ctx, time_point()).
basic_waitable_timer(basic_waitable_timer&& rhs);
5 Effects: Move constructs an object of class basic_waitable_timer<Clock, WaitTraits> that refers
to the state originally represented by rhs.
6 Postconditions:
(6.1) — get_executor() == rhs.get_executor().
(6.2) — expiry() returns the same value as rhs.expiry() prior to the constructor invocation.
(6.3) — rhs.expiry() == time_point().
ISO/IEC TS 19216:2018(E)
(2.2) — expiry() returns the same value as rhs.expiry() prior to the assignment.
(2.3) — rhs.expiry() == time_point().
3 Returns: *this.
size_t cancel();
2 Effects: Causes any outstanding asynchronous wait operations to complete. Completion handlers for
canceled operations are passed an error code ec such that ec == errc::operation_canceled yields
true.
3 Returns: The number of operations that were canceled.
4 Remarks: Does not block (C++ 2014, 17.3.2) the calling thread pending completion of the canceled
operations.
size_t cancel_one();
5 Effects: Causes the outstanding asynchronous wait operation that was initiated first, if any, to complete
as soon as possible. The completion handler for the canceled operation is passed an error code ec such
that ec == errc::operation_canceled yields true.
6 Returns: 1 if an operation was canceled, otherwise 0.
7 Remarks: Does not block (C++ 2014, 17.3.2) the calling thread pending completion of the canceled
operation.
void wait();
void wait(error_code& ec);
13 Effects: Establishes the postcondition as if by repeatedly blocking the calling thread (C++ 2014, 17.3.2)
for the relative time produced by WaitTraits::to_wait_duration(expiry()).
14 Postconditions: ec || expiry() <= clock_type::now().
template<class CompletionToken>
DEDUCED async_wait(CompletionToken&& token);
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
16 Buffers [buffer]
16.1 Header <experimental/buffer> synopsis [buffer.synop]
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
class mutable_buffer;
class const_buffer;
template<class T>
constexpr bool is_mutable_buffer_sequence_v = is_mutable_buffer_sequence<T>::value;
template<class T>
constexpr bool is_const_buffer_sequence_v = is_const_buffer_sequence<T>::value;
template<class T>
constexpr bool is_dynamic_buffer_v = is_dynamic_buffer<T>::value;
template<class ConstBufferSequence>
size_t buffer_size(const ConstBufferSequence& buffers) noexcept;
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
class transfer_all;
class transfer_at_least;
class transfer_exactly;
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
3 If a read or write operation is also an asynchronous operation (13.2.7), the operation shall maintain one or
more copies of the buffer sequence until such time as the operation no longer requires access to the memory
specified by the buffers in the sequence. The program shall ensure the memory remains valid until:
(3.1) — the last copy of the buffer sequence is destroyed, or
(3.2) — the completion handler for the asynchronous operation is invoked,
whichever comes first.
class mutable_buffer
{
public:
// constructors:
mutable_buffer() noexcept;
mutable_buffer(void* p, size_t n) noexcept;
// members:
void* data() const noexcept;
size_t size() const noexcept;
mutable_buffer& operator+=(size_t n) noexcept;
private:
void* data_; // exposition only
size_t size_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
mutable_buffer() noexcept;
2 Postconditions: data_ == nullptr and size_ == 0.
class const_buffer
{
public:
// constructors:
const_buffer() noexcept;
const_buffer(const void* p, size_t n) noexcept;
const_buffer(const mutable_buffer& b) noexcept;
// members:
const void* data() const noexcept;
size_t size() const noexcept;
const_buffer& operator+=(size_t n) noexcept;
private:
const void* data_; // exposition only
size_t size_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
1 This subclause contains templates that may be used to query the properties of a type at compile time. Each
of these templates is a UnaryTypeTrait (C++ 2014, 20.10.1) with a BaseCharacteristic of true_type if the
corresponding condition is true, otherwise false_type.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
1 Effects: Copies bytes from the buffer sequence source to the buffer sequence dest, as if by calls to
memcpy.
2 The number of bytes copied is the lesser of:
(2.1) — buffer_size(dest);
(2.2) — buffer_size(source); and
(2.3) — max_size, if specified.
3 The mutable buffer sequence dest specifies memory where the data should be placed. The operation
always fills a buffer in the sequence completely before proceeding to the next.
4 The constant buffer sequence source specifies memory where the data to be written is located. The
operation always copies a buffer in the sequence completely before proceeding to the next.
5 Returns: The number of bytes copied from source to dest.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
// constructors:
explicit dynamic_vector_buffer(vector<T, Allocator>& vec) noexcept;
dynamic_vector_buffer(vector<T, Allocator>& vec,
size_t maximum_size) noexcept;
dynamic_vector_buffer(dynamic_vector_buffer&&) = default;
// members:
size_t size() const noexcept;
size_t max_size() const noexcept;
size_t capacity() const noexcept;
const_buffers_type data() const noexcept;
mutable_buffers_type prepare(size_t n);
void commit(size_t n);
void consume(size_t n);
private:
vector<T, Allocator>& vec_; // exposition only
size_t size_; // exposition only
const size_t max_size_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
4 Effects: Initializes vec_ with vec, size_ with vec.size(), and max_size_ with vec.max_size().
ISO/IEC TS 19216:2018(E)
// types:
using const_buffers_type = const_buffer;
using mutable_buffers_type = mutable_buffer;
// constructors:
explicit dynamic_string_buffer(basic_string<CharT, Traits, Allocator>& str) noexcept;
dynamic_string_buffer(basic_string<CharT, Traits, Allocator>& str,
size_t maximum_size) noexcept;
dynamic_string_buffer(dynamic_string_buffer&&) = default;
// members:
size_t size() const noexcept;
size_t max_size() const noexcept;
size_t capacity() const noexcept;
const_buffers_type data() const noexcept;
mutable_buffers_type prepare(size_t n);
void commit(size_t n) noexcept;
void consume(size_t n);
private:
basic_string<CharT, Traits, Allocator>& str_; // exposition only
size_t size_; // exposition only
const size_t max_size_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
namespace experimental {
namespace net {
inline namespace v1 {
class transfer_all
{
public:
size_t operator()(const error_code& ec, size_t) const;
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
class transfer_at_least
{
public:
explicit transfer_at_least(size_t m);
size_t operator()(const error_code& ec, size_t n) const;
private:
size_t minimum_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
class transfer_exactly
{
public:
explicit transfer_exactly(size_t e);
size_t operator()(const error_code& ec, size_t n) const;
private:
size_t exact_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
read operation so far. The completion condition return value specifies the maximum number of bytes
to be read on the subsequent read_some call. Overloads where a completion condition is not specified
behave as if called with an object of class transfer_all.
4 The synchronous read operation continues until:
(4.1) — the total number of bytes transferred is equal to buffer_size(buffers); or
(4.2) — the completion condition returns 0.
5 On return, ec contains the error_code value from the most recent read_some call.
6 Returns: The total number of bytes transferred in the synchronous read operation.
7 Remarks: This function shall not participate in overload resolution unless is_mutable_buffer_-
sequence_v<MutableBufferSequence> is true.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
14 The program shall ensure both the AsyncWriteStream object stream and the memory associated with
the dynamic buffer b are valid until the completion handler for the asynchronous operation is invoked.
15 On completion of the asynchronous operation, ec is the error_code value from the most recent
asynchronous write_some operation, and n is the total number of bytes transferred.
16 Remarks: This function shall not participate in overload resolution unless is_dynamic_buffer_-
v<DynamicBuffer> is true.
ISO/IEC TS 19216:2018(E)
3 Effects: Initiates an asynchronous operation to read data from the buffer-oriented asynchronous read
stream (17.1.2) object stream by performing zero or more asynchronous read_some operations on the
stream, until the readable bytes of the dynamic buffer (16.2.4) object b contain the specified delimiter
delim.
4 Data is placed into the dynamic buffer object b. A mutable buffer sequence (16.2.1) is obtained
prior to each async_read_some call using b.prepare(N), where N is an unspecified value such that
N <= max_size() - size(). [ Note: Implementations can use b.capacity() when determining N,
to minimize the number of asynchronous read_some operations performed on the stream. — end
note ] After the completion of each asynchronous read_some operation, the implementation performs
b.commit(n), where n is the value passed to the asynchronous read_some operation’s completion
handler.
5 The asynchronous read_until operation continues until:
(5.1) — the readable bytes of b contain the delimiter delim; or
(5.2) — b.size() == b.max_size(); or
(5.3) — an asynchronous read_some operation fails.
6 The program shall ensure the AsyncReadStream object stream is valid until the completion handler
for the asynchronous operation is invoked.
7 If delim is of type string_view, the implementation copies the underlying sequence of characters prior
to initiating an asynchronous read_some operation on the stream. [ Note: This means that the caller
is not required to guarantee the validity of the delimiter string after the call to async_read_until
returns. — end note ]
8 On completion of the asynchronous operation, if the readable bytes of b contain the delimiter, ec
is set such that !ec is true. Otherwise, if b.size() == b.max_size(), ec is set such that ec ==
stream_errc::not_found. If b.size() < b.max_size(), ec is the error_code from the most recent
asynchronous read_some operation. n is the number of readable bytes in b up to and including the
delimiter, if present, otherwise 0.
ISO/IEC TS 19216:2018(E)
18 Sockets [socket]
18.1 Header <experimental/socket> synopsis [socket.synop]
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
// Sockets:
class socket_base;
template<class Protocol>
class basic_socket;
template<class Protocol>
class basic_datagram_socket;
template<class Protocol>
class basic_stream_socket;
template<class Protocol>
class basic_socket_acceptor;
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
ISO/IEC TS 19216:2018(E)
} // namespace experimental
} // namespace std
1 The figure below illustrates relationships between various types described in this document. A solid line from
A to B that is terminated by an open arrow indicates that A is derived from B. A solid line from A to B
that starts with a diamond and is terminated by a solid arrow indicates that A contains an object of type
B. A dotted line from A to B indicates that A is a synonym for the class template B with the specified
template argument.
2 For an object s, the conditions under which its synchronous socket operations may block the calling thread
(C++ 2014, 17.3.2) are determined as follows.
3 If:
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
3 In the table below, a denotes a (possibly const) value of type X, b denotes a value of type X, and s denotes a
(possibly const) value of a type that is convertible to size_t and denotes a size in bytes.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
3 In this document, types that satisfy the BooleanSocketOption requirements are defined as follows.
class C
{
public:
// constructors:
C () noexcept;
explicit C (bool v) noexcept;
// members:
C & operator=(bool v) noexcept;
5 Let L and N identify the POSIX macros to be passed as the level and option_name arguments, respectively,
to POSIX setsockopt and getsockopt.
C () noexcept;
6 Postconditions: !value().
ISO/IEC TS 19216:2018(E)
8 Returns: *this.
9 Postconditions: value() == v.
3 In this document, types that satisfy the IntegerSocketOption requirements are defined as follows.
ISO/IEC TS 19216:2018(E)
class C
{
public:
// constructors:
C () noexcept;
explicit C (int v) noexcept;
// members:
C & operator=(int v) noexcept;
5 Let L and N identify the POSIX macros to be passed as the level and option_name arguments, respectively,
to POSIX setsockopt and getsockopt.
C () noexcept;
6 Postconditions: !value().
ISO/IEC TS 19216:2018(E)
13 Returns: std::addressof(value_).
ISO/IEC TS 19216:2018(E)
2 The object’s default_error_condition and equivalent virtual functions behave as specified for the
class error_category. The object’s name virtual function returns a pointer to the string "socket".
class socket_base
{
public:
class broadcast;
class debug;
class do_not_route;
class keep_alive;
class linger;
class out_of_band_inline;
class receive_buffer_size;
class receive_low_watermark;
class reuse_address;
class send_buffer_size;
class send_low_watermark;
using shutdown_type = T1 ;
static constexpr shutdown_type shutdown_receive;
static constexpr shutdown_type shutdown_send;
static constexpr shutdown_type shutdown_both;
using wait_type = T2 ;
static constexpr wait_type wait_read;
static constexpr wait_type wait_write;
static constexpr wait_type wait_error;
using message_flags = T3 ;
static constexpr message_flags message_peek;
static constexpr message_flags message_out_of_band;
static constexpr message_flags message_do_not_route;
protected:
socket_base();
~socket_base();
};
} // inline namespace v1
} // namespace net
ISO/IEC TS 19216:2018(E)
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
class socket_base::linger
{
public:
// constructors:
linger() noexcept;
linger(bool e, chrono::seconds t) noexcept;
// members:
bool enabled() const noexcept;
void enabled(bool e) noexcept;
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 linger satisfies the requirements of Destructible (C++ 2014, 17.6.3.1), DefaultConstructible (C++ 2014,
17.6.3.1), CopyConstructible (C++ 2014, 17.6.3.1), CopyAssignable (C++ 2014, 17.6.3.1), GettableSocket-
Option (18.2.8), and SettableSocketOption (18.2.9).
3 Extensible implementations provide the following member functions:
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
class socket_base::linger
{
public:
template<class Protocol> int level(const Protocol& p) const noexcept;
template<class Protocol> int name(const Protocol& p) const noexcept;
template<class Protocol> void data(const Protocol& p) noexcept;
template<class Protocol> const void* data(const Protocol& p) const noexcept;
template<class Protocol> size_t size(const Protocol& p) const noexcept;
template<class Protocol> void resize(const Protocol& p, size_t s);
// remainder unchanged
private:
::linger value_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
linger() noexcept;
4 Postconditions: !enabled() && timeout() == chrono::seconds(0).
ISO/IEC TS 19216:2018(E)
template<class Protocol>
class basic_socket : public socket_base
{
public:
// types:
ISO/IEC TS 19216:2018(E)
void close();
void close(error_code& ec);
void cancel();
void cancel(error_code& ec);
template<class SettableSocketOption>
void set_option(const SettableSocketOption& option);
template<class SettableSocketOption>
void set_option(const SettableSocketOption& option, error_code& ec);
template<class GettableSocketOption>
void get_option(GettableSocketOption& option) const;
template<class GettableSocketOption>
void get_option(GettableSocketOption& option, error_code& ec) const;
template<class IoControlCommand>
void io_control(IoControlCommand& command);
template<class IoControlCommand>
void io_control(IoControlCommand& command, error_code& ec);
ISO/IEC TS 19216:2018(E)
template<class CompletionToken>
DEDUCED async_connect(const endpoint_type& endpoint,
CompletionToken&& token);
template<class CompletionToken>
DEDUCED async_wait(wait_type w, CompletionToken&& token);
protected:
// 18.6.1, construct / copy / destroy:
~basic_socket();
basic_socket& operator=(const basic_socket&) = delete;
basic_socket& operator=(basic_socket&& rhs);
template<class OtherProtocol>
basic_socket& operator=(basic_socket<OtherProtocol>&& rhs);
private:
protocol_type protocol_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Instances of class template basic_socket meet the requirements of Destructible (C++ 2014, 17.6.3.1),
MoveConstructible (C++ 2014, 17.6.3.1), and MoveAssignable (C++ 2014, 17.6.3.1).
3 When an operation has its effects specified as if by passing the result of native_handle() to a POSIX
function, then the operation fails with error condition errc::bad_file_descriptor if is_open() == false
at the point in the effects when the POSIX function is called.
ISO/IEC TS 19216:2018(E)
5 Postconditions:
(5.1) — get_executor() == ctx.get_executor().
(5.2) — is_open() == true.
(5.3) — non_blocking() == false.
(5.4) — protocol_ == endpoint.protocol().
basic_socket(basic_socket&& rhs);
9 Effects: Move constructs an object of class basic_socket<Protocol> that refers to the state originally
represented by rhs.
10 Postconditions:
(10.1) — get_executor() == rhs.get_executor().
(10.2) — is_open() returns the same value as rhs.is_open() prior to the constructor invocation.
(10.3) — non_blocking() returns the same value as rhs.non_blocking() prior to the constructor invoca-
tion.
(10.4) — native_handle() returns the prior value of rhs.native_handle().
(10.5) — protocol_ is the prior value of rhs.protocol_.
(10.6) — rhs.is_open() == false.
ISO/IEC TS 19216:2018(E)
template<class OtherProtocol>
basic_socket(basic_socket<OtherProtocol>&& rhs);
11 Requires: OtherProtocol is implicitly convertible to Protocol.
12 Effects: Move constructs an object of class basic_socket<Protocol> that refers to the state originally
represented by rhs.
13 Postconditions:
(13.1) — get_executor() == rhs.get_executor().
(13.2) — is_open() returns the same value as rhs.is_open() prior to the constructor invocation.
(13.3) — non_blocking() returns the same value as rhs.non_blocking() prior to the constructor invoca-
tion.
(13.4) — native_handle() returns the prior value of rhs.native_handle().
(13.5) — protocol_ is the result of converting the prior value of rhs.protocol_.
(13.6) — rhs.is_open() == false.
14 Remarks: This constructor shall not participate in overload resolution unless OtherProtocol is implicitly
convertible to Protocol.
template<class OtherProtocol>
basic_socket& operator=(basic_socket<OtherProtocol>&& rhs);
ISO/IEC TS 19216:2018(E)
native_handle_type native_handle();
2 Returns: The native representation of this socket.
4 Postconditions:
(4.1) — is_open() == true.
(4.2) — non_blocking() == false.
(4.3) — protocol_ == protocol.
5 Error conditions:
(5.1) — socket_errc::already_open — if is_open() == true.
ISO/IEC TS 19216:2018(E)
native_handle_type release();
native_handle_type release(error_code& ec);
10 Requires: is_open() == true.
11 Effects: Cancels all outstanding asynchronous operations associated with this socket. Comple-
tion handlers for canceled asynchronous operations are passed an error code ec such that ec ==
errc::operation_canceled yields true.
12 Returns: The native representation of this socket.
13 Postconditions: is_open() == false.
14 Remarks: Since the native socket is not closed prior to returning it, the caller is responsible for closing
it.
void close();
void close(error_code& ec);
16 Effects: If is_open() is true, cancels all outstanding asynchronous operations associated with
this socket, and establishes the postcondition as if by POSIX close(native_handle()). Comple-
tion handlers for canceled asynchronous operations are passed an error code ec such that ec ==
errc::operation_canceled yields true.
17 Postconditions: is_open() == false.
void cancel();
void cancel(error_code& ec);
18 Effects: Cancels all outstanding asynchronous operations associated with this socket. Comple-
tion handlers for canceled asynchronous operations are passed an error code ec such that ec ==
errc::operation_canceled yields true.
19 Error conditions:
(19.1) — errc::bad_file_descriptor — if is_open() is false.
20 Remarks: Does not block (C++ 2014, 17.3.2) the calling thread pending completion of the canceled
operations.
template<class SettableSocketOption>
void set_option(const SettableSocketOption& option);
template<class SettableSocketOption>
void set_option(const SettableSocketOption& option, error_code& ec);
21 Effects: Sets an option on this socket, as if by POSIX:
setsockopt(native_handle(), option.level(protocol_), option.name(protocol_),
option.data(protocol_), option.size(protocol_));
ISO/IEC TS 19216:2018(E)
template<class GettableSocketOption>
void get_option(GettableSocketOption& option);
template<class GettableSocketOption>
void get_option(GettableSocketOption& option, error_code& ec);
22 Effects: Gets an option from this socket, as if by POSIX:
socklen_t option_len = option.size(protocol_);
int result = getsockopt(native_handle(), option.level(protocol_),
option.name(protocol_), option.data(protocol_),
&option_len);
if (result == 0)
option.resize(option_len);
template<class IoControlCommand>
void io_control(IoControlCommand& command);
template<class IoControlCommand>
void io_control(IoControlCommand& command, error_code& ec);
23 Effects: Executes an I/O control command on this socket, as if by POSIX:
ioctl(native_handle(), command.name(), command.data());
30 The native non-blocking mode has no effect on the behavior of the synchronous or asynchronous
operations specified in this clause.
31 Error conditions:
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
template<class CompletionToken>
DEDUCED async_connect(const endpoint_type& endpoint, CompletionToken&& token);
45 Completion signature: void(error_code ec).
46 Effects: If is_open() is false, opens this socket by performing open(endpoint.protocol(), ec). If
ec, the operation completes immediately with no further action. Initiates an asynchronous operation
to connect this socket to the specified remote endpoint, as if by POSIX connect(native_handle(),
endpoint.data(), endpoint.size()).
47 When an asynchronous connect operation on this socket is simultaneously outstanding with another
asynchronous connect, read, or write operation on this socket, the behavior is undefined.
48 If a program performs a synchronous operation on this socket, other than close or cancel, while there
is an outstanding asynchronous connect operation, the behavior is undefined.
template<class CompletionToken>
DEDUCED async_wait(wait_type w, CompletionToken&& token);
51 Completion signature: void(error_code ec).
52 Effects: Initiates an asynchronous operation to wait for this socket to be ready to read, ready to write,
or to have error conditions pending, as if by POSIX poll.
53 When there are multiple outstanding asynchronous wait operations on this socket with the same
wait_type value, all of these operations complete when this socket enters the corresponding ready
state. The order of invocation of the completion handlers for these operations is unspecified.
54 Error conditions:
(54.1) — errc::bad_file_descriptor — if is_open() is false.
ISO/IEC TS 19216:2018(E)
template<class Protocol>
class basic_datagram_socket : public basic_socket<Protocol>
{
public:
// types:
~basic_datagram_socket();
basic_datagram_socket& operator=(const basic_datagram_socket&) = delete;
basic_datagram_socket& operator=(basic_datagram_socket&& rhs);
template<class OtherProtocol>
basic_datagram_socket& operator=(basic_datagram_socket<OtherProtocol>&& rhs);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
error_code& ec);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags, error_code& ec);
ISO/IEC TS 19216:2018(E)
CompletionToken&& token);
template<class MutableBufferSequence>
size_t receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender);
template<class MutableBufferSequence>
size_t receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender, error_code& ec);
template<class MutableBufferSequence>
size_t receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender,
socket_base::message_flags flags);
template<class MutableBufferSequence>
size_t receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender,
socket_base::message_flags flags,
error_code& ec);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers, error_code& ec);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers,
socket_base::message_flags flags);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers,
socket_base::message_flags flags, error_code& ec);
ISO/IEC TS 19216:2018(E)
template<class ConstBufferSequence>
size_t send_to(const ConstBufferSequence& buffers,
const endpoint_type& recipient);
template<class ConstBufferSequence>
size_t send_to(const ConstBufferSequence& buffers,
const endpoint_type& recipient, error_code& ec);
template<class ConstBufferSequence>
size_t send_to(const ConstBufferSequence& buffers,
const endpoint_type& recipient,
socket_base::message_flags flags);
template<class ConstBufferSequence>
size_t send_to(const ConstBufferSequence& buffers,
const endpoint_type& recipient,
socket_base::message_flags flags, error_code& ec);
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Instances of class template basic_datagram_socket meet the requirements of Destructible (C++ 2014,
17.6.3.1), MoveConstructible (C++ 2014, 17.6.3.1), and MoveAssignable (C++ 2014, 17.6.3.1).
3 If a program performs a synchronous operation on this socket, other than close, cancel, shutdown, send,
or send_to, while there is an outstanding asynchronous read operation, the behavior is undefined.
4 If a program performs a synchronous operation on this socket, other than close, cancel, shutdown, receive,
or receive_from, while there is an outstanding asynchronous write operation, the behavior is undefined.
5 When an operation has its effects specified as if by passing the result of native_handle() to a POSIX
function, then the operation fails with error condition errc::bad_file_descriptor if is_open() == false
at the point in the effects when the POSIX function is called.
6 If native_handle_type and basic_socket<Protocol>::native_handle_type are both defined then they
name the same type.
ISO/IEC TS 19216:2018(E)
basic_datagram_socket(basic_datagram_socket&& rhs);
5 Effects: Move constructs an object of class basic_datagram_socket<Protocol>, initializing the base
class with basic_socket<Protocol>(std::move(rhs)).
template<class OtherProtocol>
basic_datagram_socket(basic_datagram_socket<OtherProtocol>&& rhs);
6 Requires: OtherProtocol is implicitly convertible to Protocol.
7 Effects: Move constructs an object of class basic_datagram_socket<Protocol>, initializing the base
class with basic_socket<Protocol>(std::move(rhs)).
8 Remarks: This constructor shall not participate in overload resolution unless OtherProtocol is implicitly
convertible to Protocol.
template<class OtherProtocol>
basic_datagram_socket& operator=(basic_datagram_socket<OtherProtocol>&& rhs);
3 Requires: OtherProtocol is implicitly convertible to Protocol.
4 Effects: Equivalent to basic_socket<Protocol>::operator=(std::move(rhs)).
5 Returns: *this.
6 Remarks: This assignment operator shall not participate in overload resolution unless OtherProtocol
is implicitly convertible to Protocol.
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags, error_code& ec);
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
template<class MutableBufferSequence>
size_t receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender);
template<class MutableBufferSequence>
size_t receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender, error_code& ec);
12 Returns: receive_from(buffers, sender, socket_base::message_flags(), ec).
template<class MutableBufferSequence>
size_t receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender,
socket_base::message_flags flags);
template<class MutableBufferSequence>
size_t receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender,
socket_base::message_flags flags,
error_code& ec);
13 A read operation (16.2.5).
14 Effects: Constructs an array iov of POSIX type struct iovec and length iovlen, corresponding to
buffers, and reads data from this socket as if by POSIX:
msghdr message;
message.msg_name = sender.data();
message.msg_namelen = sender.capacity();
message.msg_iov = iov;
message.msg_iovlen = iovlen;
message.msg_control = nullptr;
message.msg_controllen = 0;
message.msg_flags = 0;
ssize_t result = recvmsg(native_handle(), &message, static_cast<int>(flags));
if (result >= 0)
sender.resize(message.msg_namelen);
ISO/IEC TS 19216:2018(E)
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers, error_code& ec);
24 Returns: send(buffers, socket_base::message_flags(), ec).
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers,
socket_base::message_flags flags);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers,
socket_base::message_flags flags, error_code& ec);
25 A write operation (16.2.5).
26 Effects: Constructs an array iov of POSIX type struct iovec and length iovlen, corresponding to
buffers, and writes data to this socket as if by POSIX:
msghdr message;
message.msg_name = nullptr;
message.msg_namelen = 0;
message.msg_iov = iov;
message.msg_iovlen = iovlen;
message.msg_control = nullptr;
message.msg_controllen = 0;
message.msg_flags = 0;
sendmsg(native_handle(), &message, static_cast<int>(flags));
ISO/IEC TS 19216:2018(E)
template<class ConstBufferSequence>
size_t send_to(const ConstBufferSequence& buffers,
const endpoint_type& recipient);
template<class ConstBufferSequence>
size_t send_to(const ConstBufferSequence& buffers,
const endpoint_type& recipient, error_code& ec);
33 Returns: send_to(buffers, recipient, socket_base::message_flags(), ec).
template<class ConstBufferSequence>
size_t send_to(const ConstBufferSequence& buffers,
const endpoint_type& recipient,
socket_base::message_flags flags);
template<class ConstBufferSequence>
size_t send_to(const ConstBufferSequence& buffers,
const endpoint_type& recipient,
socket_base::message_flags flags, error_code& ec);
34 A write operation (16.2.5).
35 Effects: Constructs an array iov of POSIX type struct iovec and length iovlen, corresponding to
buffers, and writes data to this socket as if by POSIX:
msghdr message;
message.msg_name = recipient.data();
message.msg_namelen = recipient.size();
message.msg_iov = iov;
ISO/IEC TS 19216:2018(E)
message.msg_iovlen = iovlen;
message.msg_control = nullptr;
message.msg_controllen = 0;
message.msg_flags = 0;
sendmsg(native_handle(), &message, static_cast<int>(flags));
template<class Protocol>
class basic_stream_socket : public basic_socket<Protocol>
{
public:
ISO/IEC TS 19216:2018(E)
// types:
~basic_stream_socket();
basic_stream_socket& operator=(const basic_stream_socket&) = delete;
basic_stream_socket& operator=(basic_stream_socket&& rhs);
template<class OtherProtocol>
basic_stream_socket& operator=(basic_stream_socket<OtherProtocol>&& rhs);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
error_code& ec);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags, error_code& ec);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers, error_code& ec);
template<class ConstBufferSequence>
ISO/IEC TS 19216:2018(E)
template<class MutableBufferSequence>
size_t read_some(const MutableBufferSequence& buffers);
template<class MutableBufferSequence>
size_t read_some(const MutableBufferSequence& buffers,
error_code& ec);
template<class ConstBufferSequence>
size_t write_some(const ConstBufferSequence& buffers);
template<class ConstBufferSequence>
size_t write_some(const ConstBufferSequence& buffers,
error_code& ec);
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Instances of class template basic_stream_socket meet the requirements of Destructible (C++ 2014,
17.6.3.1), MoveConstructible (C++ 2014, 17.6.3.1), MoveAssignable (C++ 2014, 17.6.3.1), SyncRead-
Stream (17.1.1), SyncWriteStream (17.1.3), AsyncReadStream (17.1.2), and AsyncWriteStream (17.1.4).
3 If a program performs a synchronous operation on this socket, other than close, cancel, shutdown, or send,
while there is an outstanding asynchronous read operation, the behavior is undefined.
4 If a program performs a synchronous operation on this socket, other than close, cancel, shutdown, or
receive, while there is an outstanding asynchronous write operation, the behavior is undefined.
5 When an operation has its effects specified as if by passing the result of native_handle() to a POSIX
function, then the operation fails with error condition errc::bad_file_descriptor if is_open() == false
at the point in the effects when the POSIX function is called.
6 If native_handle_type and basic_socket<Protocol>::native_handle_type are both defined then they
name the same type.
ISO/IEC TS 19216:2018(E)
basic_stream_socket(basic_stream_socket&& rhs);
5 Effects: Move constructs an object of class basic_stream_socket<Protocol>, initializing the base
class with basic_socket<Protocol>(std::move(rhs)).
template<class OtherProtocol>
basic_stream_socket(basic_stream_socket<OtherProtocol>&& rhs);
6 Requires: OtherProtocol is implicitly convertible to Protocol.
7 Effects: Move constructs an object of class basic_stream_socket<Protocol>, initializing the base
class with basic_socket<Protocol>(std::move(rhs)).
8 Remarks: This constructor shall not participate in overload resolution unless OtherProtocol is implicitly
convertible to Protocol.
template<class OtherProtocol>
basic_stream_socket& operator=(basic_stream_socket<OtherProtocol>&& rhs);
3 Requires: OtherProtocol is implicitly convertible to Protocol.
4 Effects: Equivalent to basic_socket<Protocol>::operator=(std::move(rhs)).
5 Returns: *this.
6 Remarks: This assignment operator shall not participate in overload resolution unless OtherProtocol
is implicitly convertible to Protocol.
ISO/IEC TS 19216:2018(E)
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags);
template<class MutableBufferSequence>
size_t receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags, error_code& ec);
2 A read operation (16.2.5).
3 Effects: If buffer_size(buffers) == 0, returns immediately with no error. Otherwise, constructs
an array iov of POSIX type struct iovec and length iovlen, corresponding to buffers, and reads
data from this socket as if by POSIX:
msghdr message;
message.msg_name = nullptr;
message.msg_namelen = 0;
message.msg_iov = iov;
message.msg_iovlen = iovlen;
message.msg_control = nullptr;
message.msg_controllen = 0;
message.msg_flags = 0;
recvmsg(native_handle(), &message, static_cast<int>(flags));
4 Returns: On success, the number of bytes received. Otherwise 0.
5 Error conditions:
(5.1) — stream_errc::eof — if there is no data to be received and the peer performed an orderly
shutdown.
ISO/IEC TS 19216:2018(E)
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers, error_code& ec);
12 Returns: send(buffers, socket_base::message_flags(), ec).
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers,
socket_base::message_flags flags);
template<class ConstBufferSequence>
size_t send(const ConstBufferSequence& buffers,
socket_base::message_flags flags, error_code& ec);
13 A write operation (16.2.5).
14 Effects: If buffer_size(buffers) == 0, returns immediately with no error. Otherwise, constructs
an array iov of POSIX type struct iovec and length iovlen, corresponding to buffers, and writes
data to this socket as if by POSIX:
msghdr message;
message.msg_name = nullptr;
message.msg_namelen = 0;
message.msg_iov = iov;
message.msg_iovlen = iovlen;
message.msg_control = nullptr;
message.msg_controllen = 0;
message.msg_flags = 0;
sendmsg(native_handle(), &message, static_cast<int>(flags));
ISO/IEC TS 19216:2018(E)
msghdr message;
message.msg_name = nullptr;
message.msg_namelen = 0;
message.msg_iov = iov;
message.msg_iovlen = iovlen;
message.msg_control = nullptr;
message.msg_controllen = 0;
message.msg_flags = 0;
sendmsg(native_handle(), &message, static_cast<int>(flags));
template<class MutableBufferSequence>
size_t read_some(const MutableBufferSequence& buffers);
template<class MutableBufferSequence>
size_t read_some(const MutableBufferSequence& buffers,
error_code& ec);
21 Returns: receive(buffers, ec).
template<class ConstBufferSequence>
size_t write_some(const ConstBufferSequence& buffers);
template<class ConstBufferSequence>
size_t write_some(const ConstBufferSequence& buffers,
error_code& ec);
23 Returns: send(buffers, ec).
template<class AcceptableProtocol>
class basic_socket_acceptor : public socket_base
{
public:
// types:
ISO/IEC TS 19216:2018(E)
~basic_socket_acceptor();
basic_socket_acceptor& operator=(const basic_socket_acceptor&) = delete;
basic_socket_acceptor& operator=(basic_socket_acceptor&& rhs);
template<class OtherProtocol>
basic_socket_acceptor& operator=(basic_socket_acceptor<OtherProtocol>&& rhs);
void close();
void close(error_code& ec);
void cancel();
void cancel(error_code& ec);
template<class SettableSocketOption>
void set_option(const SettableSocketOption& option);
template<class SettableSocketOption>
void set_option(const SettableSocketOption& option, error_code& ec);
ISO/IEC TS 19216:2018(E)
template<class GettableSocketOption>
void get_option(GettableSocketOption& option) const;
template<class GettableSocketOption>
void get_option(GettableSocketOption& option, error_code& ec) const;
template<class IoControlCommand>
void io_control(IoControlCommand& command);
template<class IoControlCommand>
void io_control(IoControlCommand& command, error_code& ec);
socket_type accept();
socket_type accept(error_code& ec);
socket_type accept(io_context& ctx);
socket_type accept(io_context& ctx, error_code& ec);
template<class CompletionToken>
DEDUCED async_accept(CompletionToken&& token);
template<class CompletionToken>
DEDUCED async_accept(io_context& ctx, CompletionToken&& token);
template<class CompletionToken>
DEDUCED async_accept(endpoint_type& endpoint,
CompletionToken&& token);
template<class CompletionToken>
DEDUCED async_accept(io_context& ctx, endpoint_type& endpoint,
CompletionToken&& token);
ISO/IEC TS 19216:2018(E)
template<class CompletionToken>
DEDUCED async_wait(wait_type w, CompletionToken&& token);
private:
protocol_type protocol_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Instances of class template basic_socket_acceptor meet the requirements of Destructible (C++ 2014,
17.6.3.1), MoveConstructible (C++ 2014, 17.6.3.1), and MoveAssignable (C++ 2014, 17.6.3.1).
3 When there are multiple outstanding asynchronous accept operations the order in which the incoming
connections are dequeued, and the order of invocation of the completion handlers for these operations, is
unspecified.
4 When an operation has its effects specified as if by passing the result of native_handle() to a POSIX
function, then the operation fails with error condition errc::bad_file_descriptor if is_open() == false
at the point in the effects when the POSIX function is called.
ISO/IEC TS 19216:2018(E)
5 Postconditions:
(5.1) — get_executor() == ctx.get_executor().
(5.2) — is_open() == true.
(5.3) — non_blocking() == false.
(5.4) — enable_connection_aborted() == false.
(5.5) — protocol_ == endpoint.protocol().
basic_socket_acceptor(basic_socket_acceptor&& rhs);
9 Effects: Move constructs an object of class basic_socket_acceptor<AcceptableProtocol> that refers
to the state originally represented by rhs.
10 Postconditions:
(10.1) — get_executor() == rhs.get_executor().
(10.2) — is_open() returns the same value as rhs.is_open() prior to the constructor invocation.
(10.3) — non_blocking() returns the same value as rhs.non_blocking() prior to the constructor invoca-
tion.
(10.4) — enable_connection_aborted() returns the same value as rhs.enable_connection_aborted()
prior to the constructor invocation.
(10.5) — native_handle() returns the same value as rhs.native_handle() prior to the constructor
invocation.
(10.6) — protocol_ is equal to the prior value of rhs.protocol_.
(10.7) — rhs.is_open() == false.
template<class OtherProtocol>
basic_socket_acceptor(basic_socket_acceptor<OtherProtocol>&& rhs);
11 Requires: OtherProtocol is implicitly convertible to Protocol.
12 Effects: Move constructs an object of class basic_socket_acceptor<AcceptableProtocol> that refers
to the state originally represented by rhs.
13 Postconditions:
(13.1) — get_executor() == rhs.get_executor().
ISO/IEC TS 19216:2018(E)
(13.2) — is_open() returns the same value as rhs.is_open() prior to the constructor invocation.
(13.3) — non_blocking() returns the same value as rhs.non_blocking() prior to the constructor invoca-
tion.
(13.4) — enable_connection_aborted() returns the same value as rhs.enable_connection_aborted()
prior to the constructor invocation.
(13.5) — native_handle() returns the prior value of rhs.native_handle().
(13.6) — protocol_ is the result of converting the prior value of rhs.protocol_.
(13.7) — rhs.is_open() == false.
14 Remarks: This constructor shall not participate in overload resolution unless OtherProtocol is implicitly
convertible to Protocol.
template<class OtherProtocol>
basic_socket_acceptor& operator=(basic_socket_acceptor<OtherProtocol>&& rhs);
4 Requires: OtherProtocol is implicitly convertible to Protocol.
5 Effects: If is_open() is true, cancels all outstanding asynchronous operations associated with this
acceptor, and releases acceptor resources as if by POSIX close(native_handle()). Then moves into
*this the state originally represented by rhs. Completion handlers for canceled operations are passed
an error code ec such that ec == errc::operation_canceled yields true.
6 Postconditions:
ISO/IEC TS 19216:2018(E)
native_handle_type native_handle();
2 Returns: The native representation of this acceptor.
4 Postconditions:
(4.1) — is_open() == true.
(4.2) — non_blocking() == false.
(4.3) — enable_connection_aborted() == false.
(4.4) — protocol_ == protocol.
5 Error conditions:
(5.1) — socket_errc::already_open — if is_open() is true.
ISO/IEC TS 19216:2018(E)
native_handle_type release();
native_handle_type release(error_code& ec);
10 Requires: is_open() == true.
11 Effects: Cancels all outstanding asynchronous operations associated with this acceptor. Comple-
tion handlers for canceled asynchronous operations are passed an error code ec such that ec ==
errc::operation_canceled yields true.
12 Returns: The native representation of this acceptor.
13 Postconditions: is_open() == false.
14 Remarks: Since the native acceptor is not closed prior to returning it, the caller is responsible for
closing it.
void close();
void close(error_code& ec);
16 Effects: If is_open() is true, cancels all outstanding asynchronous operations associated with this
acceptor, and establishes the postcondition as if by POSIX close(native_handle()). Comple-
tion handlers for canceled asynchronous operations are passed an error code ec such that ec ==
errc::operation_canceled yields true.
17 Postconditions: is_open() == false.
void cancel();
void cancel(error_code& ec);
18 Effects: Cancels all outstanding asynchronous operations associated with this acceptor. Comple-
tion handlers for canceled asynchronous operations are passed an error code ec such that ec ==
errc::operation_canceled yields true.
19 Error conditions:
(19.1) — errc::bad_file_descriptor — if is_open() is false.
(19.2) — errc::operation_not_supported — current conditions do not permit cancelation. The condi-
tions under which cancelation of asynchronous operations is permitted are implementation-defined.
template<class SettableSocketOption>
void set_option(const SettableSocketOption& option);
template<class SettableSocketOption>
void set_option(const SettableSocketOption& option, error_code& ec);
20 Effects: Sets an option on this acceptor, as if by POSIX:
setsockopt(native_handle(), option.level(protocol_), option.name(protocol_),
option.data(protocol_), option.size(protocol_));
ISO/IEC TS 19216:2018(E)
template<class GettableSocketOption>
void get_option(GettableSocketOption& option);
template<class GettableSocketOption>
void get_option(GettableSocketOption& option, error_code& ec);
21 Effects: Gets an option from this acceptor, as if by POSIX:
socklen_t option_len = option.size(protocol_);
int result = getsockopt(native_handle(), option.level(protocol_),
option.name(protocol_), option.data(protocol_),
&option_len);
if (result == 0)
option.resize(option_len);
template<class IoControlCommand>
void io_control(IoControlCommand& command);
template<class IoControlCommand>
void io_control(IoControlCommand& command, error_code& ec);
22 Effects: Executes an I/O control command on this acceptor, as if by POSIX:
ioctl(native_handle(), command.name(), command.data());
29 The native non-blocking mode has no effect on the behavior of the synchronous or asynchronous
operations specified in this clause.
30 Error conditions:
ISO/IEC TS 19216:2018(E)
socket_type accept();
socket_type accept(error_code& ec);
ISO/IEC TS 19216:2018(E)
template<class CompletionToken>
DEDUCED async_accept(CompletionToken&& token);
43 Returns:
async_accept(get_executor().context(), forward<CompletionToken>(token))
template<class CompletionToken>
DEDUCED async_accept(io_context& ctx, CompletionToken&& token);
44 Completion signature: void(error_code ec, socket_type s).
45 Effects: Initiates an asynchronous operation to extract a socket from the queue of pending connections
of the acceptor, as if by POSIX:
native_handle_type h = accept(native_handle(), nullptr, 0);
template<class CompletionToken>
DEDUCED async_accept(endpoint_type& endpoint,
CompletionToken&& token);
49 Returns:
async_accept(get_executor().context(), endpoint, forward<CompletionToken>(token))
template<class CompletionToken>
DEDUCED async_accept(io_context& ctx, endpoint_type& endpoint,
CompletionToken&& token);
ISO/IEC TS 19216:2018(E)
template<class CompletionToken>
DEDUCED async_wait(wait_type w, CompletionToken&& token);
53 Completion signature: void(error_code ec).
54 Effects: Initiates an asynchronous operation to wait for the acceptor to have a queued incoming
connection, or to have error conditions pending, as if by POSIX poll.
55 When multiple asynchronous wait operations are initiated with the same wait_type value, all out-
standing operations complete when the acceptor enters the corresponding ready state. The order of
invocation of the completions handlers for these operations is unspecified.
56 Error conditions:
(56.1) — errc::bad_file_descriptor — if is_open() is false.
ISO/IEC TS 19216:2018(E)
basic_socket_streambuf();
explicit basic_socket_streambuf(basic_stream_socket<protocol_type> s);
basic_socket_streambuf(const basic_socket_streambuf&) = delete;
basic_socket_streambuf(basic_socket_streambuf&& rhs);
virtual ~basic_socket_streambuf();
basic_socket_streambuf& operator=(const basic_socket_streambuf&) = delete;
basic_socket_streambuf& operator=(basic_socket_streambuf&& rhs);
// 19.1.2, members:
basic_socket_streambuf* close();
basic_socket<protocol_type>& socket();
error_code error() const;
ISO/IEC TS 19216:2018(E)
protected:
// overridden virtual functions:
virtual int_type underflow() override;
virtual int_type pbackfail(int_type c = traits_type::eof()) override;
virtual int_type overflow(int_type c = traits_type::eof()) override;
virtual int sync() override;
virtual streambuf* setbuf(char_type* s, streamsize n) override;
private:
basic_stream_socket<protocol_type> socket_; // exposition only
error_code ec_; // exposition only
time_point expiry_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
3 Instances of class template basic_socket_streambuf meet the requirements of Destructible (C++ 2014,
17.6.3.1), MoveConstructible (C++ 2014, 17.6.3.1), and MoveAssignable (C++ 2014, 17.6.3.1).
basic_socket_streambuf(basic_socket_streambuf&& rhs);
5 Effects: Move constructs from the rvalue rhs. It is implementation-defined whether the sequence
pointers in *this (eback(), gptr(), egptr(), pbase(), pptr(), epptr()) obtain the values which
rhs had. Whether they do or not, *this and rhs reference separate buffers (if any at all) after the
construction. Additionally *this references the socket which rhs did before the construction, and rhs
references no open socket after the construction.
6 Postconditions: Let rhs_p refer to the state of rhs just prior to this construction and let rhs_a refer
to the state of rhs just after this construction.
(6.1) — is_open() == rhs_p.is_open()
(6.2) — rhs_a.is_open() == false
(6.3) — error() == rhs_p.error()
(6.4) — !rhs_a.error()
(6.5) — expiry() == rhs_p.expiry()
(6.6) — rhs_a.expiry() == time_point::max()
(6.7) — gptr() - eback() == rhs_p.gptr() - rhs_p.eback()
ISO/IEC TS 19216:2018(E)
virtual ~basic_socket_streambuf();
7 Effects: If a put area exists, calls overflow(traits_type::eof()) to flush characters. [ Note: The
socket is closed by the basic_stream_socket<protocol_type> destructor. — end note ]
template<class... Args>
basic_socket_streambuf* connect(Args&&... args);
3 Effects: Initializes the basic_socket_streambuf as required and closes the socket as if by call-
ing socket_.close(ec_). Obtains an endpoint sequence endpoints by performing protocol_-
type::resolver(ctx).resolve(forward<Args>(args)...), where ctx is an unspecified object of
class io_context. For each endpoint e in the sequence, closes and re-opens the socket by performing
socket_.close(ec_) and socket_.open(e.protocol(), ec_), then attempts to establish a connec-
tion as if by POSIX connect(socket_.native_handle(), static_cast<sockaddr*>(e.data()),
e.size()). ec_ is set to reflect the error code produced by the operation. If the operation does
not complete before the absolute timeout specified by expiry_, the socket is closed and ec_ is set to
errc::timed_out.
4 Returns: if !ec_, this; otherwise, a null pointer.
5 Remarks: This function shall not participate in overload resolution unless Protocol meets the require-
ments for an internet protocol (21.2.1).
basic_socket_streambuf* close();
ISO/IEC TS 19216:2018(E)
basic_socket<protocol_type>& socket();
9 Returns: socket_.
ISO/IEC TS 19216:2018(E)
basic_socket_iostream();
explicit basic_socket_iostream(basic_stream_socket<protocol_type> s);
basic_socket_iostream(const basic_socket_iostream&) = delete;
ISO/IEC TS 19216:2018(E)
basic_socket_iostream(basic_socket_iostream&& rhs);
template<class... Args>
explicit basic_socket_iostream(Args&&... args);
// 19.2.2, members:
void close();
basic_socket<protocol_type>& socket();
error_code error() const;
private:
basic_socket_streambuf<protocol_type, clock_type, wait_traits_type> sb_; // exposition only
};
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
3 Instances of class template basic_socket_iostream meet the requirements of Destructible (C++ 2014,
17.6.3.1), MoveConstructible (C++ 2014, 17.6.3.1), and MoveAssignable (C++ 2014, 17.6.3.1).
ISO/IEC TS 19216:2018(E)
void close();
2 Effects: Calls rdbuf()->close(). If that function returns a null pointer, calls setstate(failbit)
(which may throw ios_base::failure).
basic_socket<protocol_type>& socket();
5 Returns: rdbuf()->socket().
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
class address;
class address_v4;
class address_v6;
class bad_address_cast;
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
class network_v4;
class network_v6;
template<class InternetProtocol>
class basic_endpoint;
ISO/IEC TS 19216:2018(E)
template<class InternetProtocol>
class basic_resolver_entry;
template<class InternetProtocol>
bool operator==(const basic_resolver_entry<InternetProtocol>&,
const basic_resolver_entry<InternetProtocol>&);
template<class InternetProtocol>
bool operator!=(const basic_resolver_entry<InternetProtocol>&,
const basic_resolver_entry<InternetProtocol>&);
template<class InternetProtocol>
class basic_resolver_results;
template<class InternetProtocol>
bool operator==(const basic_resolver_results<InternetProtocol>&,
const basic_resolver_results<InternetProtocol>&);
template<class InternetProtocol>
bool operator!=(const basic_resolver_results<InternetProtocol>&,
const basic_resolver_results<InternetProtocol>&);
class resolver_base;
template<class InternetProtocol>
class basic_resolver;
string host_name();
string host_name(error_code&);
template<class Allocator>
basic_string<char, char_traits<char>, Allocator>
host_name(const Allocator&);
template<class Allocator>
basic_string<char, char_traits<char>, Allocator>
host_name(const Allocator&, error_code&);
ISO/IEC TS 19216:2018(E)
class tcp;
class udp;
class v6_only;
namespace unicast {
class hops;
} // namespace unicast
namespace multicast {
class join_group;
class leave_group;
class outbound_interface;
class hops;
class enable_loopback;
} // namespace multicast
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
3 In this document, types that satisfy the MulticastGroupSocketOption requirements are defined as follows.
class C
{
public:
// constructors:
explicit C (const address& multicast_group) noexcept;
explicit C (const address_v4& multicast_group,
const address_v4& network_interface = address_v4::any()) noexcept;
explicit C (const address_v6& multicast_group,
unsigned int network_interface = 0) noexcept;
};
ISO/IEC TS 19216:2018(E)
{
public:
template<class Protocol> int level(const Protocol& p) const noexcept;
template<class Protocol> int name(const Protocol& p) const noexcept;
template<class Protocol> const void* data(const Protocol& p) const noexcept;
template<class Protocol> size_t size(const Protocol& p) const noexcept;
// remainder unchanged
private:
ip_mreq v4_value_; // exposition only
ipv6_mreq v6_value_; // exposition only
};
5 Let L and N identify the POSIX macros to be passed as the level and option_name arguments, respectively,
to POSIX setsockopt and getsockopt.
explicit C (const address& multicast_group) noexcept;
6 Effects: If multicast_group.is_v6() is true, calls C (multicast_group.to_v6()); otherwise, calls
C (multicast_group.to_v4()).
ISO/IEC TS 19216:2018(E)
class address
{
public:
// 21.4.1, constructors:
constexpr address() noexcept;
constexpr address(const address& a) noexcept;
constexpr address(const address_v4& a) noexcept;
constexpr address(const address_v6& a) noexcept;
// 21.4.2, assignment:
address& operator=(const address& a) noexcept;
address& operator=(const address_v4& a) noexcept;
address& operator=(const address_v6& a) noexcept;
// 21.4.3, members:
constexpr bool is_v4() const noexcept;
constexpr bool is_v6() const noexcept;
constexpr address_v4 to_v4() const;
constexpr address_v6 to_v6() const;
constexpr bool is_unspecified() const noexcept;
constexpr bool is_loopback() const noexcept;
constexpr bool is_multicast() const noexcept;
template<class Allocator = allocator<char>>
basic_string<char, char_traits<char>, Allocator>
to_string(const Allocator& a = Allocator()) const;
private:
address_v4 v4_; // exposition only
address_v6 v6_; // exposition only
};
ISO/IEC TS 19216:2018(E)
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 address satisfies the requirements for Destructible (C++ 2014, 17.6.3.1), CopyConstructible (C++ 2014,
17.6.3.1), and CopyAssignable (C++ 2014, 17.6.3.1).
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
2 Returns: a.
class address_v4
{
public:
// 21.5.1, types:
using uint_type = uint_least32_t;
struct bytes_type;
// 21.5.2, constructors:
ISO/IEC TS 19216:2018(E)
// assignment:
address_v4& operator=(const address_v4& a) noexcept;
// 21.5.3, members:
constexpr bool is_unspecified() const noexcept;
constexpr bool is_loopback() const noexcept;
constexpr bool is_multicast() const noexcept;
constexpr bytes_type to_bytes() const noexcept;
constexpr uint_type to_uint() const noexcept;
template<class Allocator = allocator<char>>
basic_string<char, char_traits<char>, Allocator>
to_string(const Allocator& a = Allocator()) const;
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 address_v4 satisfies the requirements for Destructible (C++ 2014, 17.6.3.1), CopyConstructible (C++
ISO/IEC TS 19216:2018(E)
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
class address_v6
{
public:
// 21.6.1, types:
struct bytes_type;
ISO/IEC TS 19216:2018(E)
// 21.6.2, constructors:
constexpr address_v6() noexcept;
constexpr address_v6(const address_v6& a) noexcept;
constexpr address_v6(const bytes_type& bytes,
scope_id_type scope = 0);
// assignment:
address_v6& operator=(const address_v6& a) noexcept;
// 21.6.3, members:
void scope_id(scope_id_type id) noexcept;
constexpr scope_id_type scope_id() const noexcept;
constexpr bool is_unspecified() const noexcept;
constexpr bool is_loopback() const noexcept;
constexpr bool is_multicast() const noexcept;
constexpr bool is_link_local() const noexcept;
constexpr bool is_site_local() const noexcept;
constexpr bool is_v4_mapped() const noexcept;
constexpr bool is_multicast_node_local() const noexcept;
constexpr bool is_multicast_link_local() const noexcept;
constexpr bool is_multicast_site_local() const noexcept;
constexpr bool is_multicast_org_local() const noexcept;
constexpr bool is_multicast_global() const noexcept;
constexpr bytes_type to_bytes() const noexcept;
template<class Allocator = allocator<char>>
basic_string<char, char_traits<char>, Allocator>
to_string(const Allocator& a = Allocator()) const;
ISO/IEC TS 19216:2018(E)
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 address_v6 satisfies the requirements for Destructible (C++ 2014, 17.6.3.1), CopyConstructible (C++
2014, 17.6.3.1), and CopyAssignable (C++ 2014, 17.6.3.1).
3 [ Note: The implementations of the functions is_unspecified, is_loopback, is_multicast, is_link_-
local, is_site_local, is_v4_mapped, is_multicast_node_local, is_multicast_link_local, is_mul-
ticast_site_local, is_multicast_org_local and is_multicast_global are determined by [RFC4291].
— end note ]
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
// constructor:
bad_address_cast() noexcept;
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
bad_address_cast() noexcept;
2 Effects: constructs a bad_address_cast object.
3 Postconditions: what() returns an implementation-defined ntbs.
// constructors:
basic_address_iterator(const Address & a) noexcept;
// members:
reference operator*() const noexcept;
pointer operator->() const noexcept;
basic_address_iterator& operator++() noexcept;
basic_address_iterator operator++(int) noexcept;
basic_address_iterator& operator--() noexcept;
ISO/IEC TS 19216:2018(E)
private:
Address address_; // exposition only
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Specializations of basic_address_iterator satisfy the requirements for input iterators (C++ 2014, 24.2.3).
basic_address_iterator(const Address & a) noexcept;
3 Effects: Initializes address_ with a.
ISO/IEC TS 19216:2018(E)
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
namespace ip {
// constructors:
basic_address_range() noexcept;
basic_address_range(const Address & first,
const Address & last) noexcept;
// members:
iterator begin() const noexcept;
iterator end() const noexcept;
bool empty() const noexcept;
size_t size() const noexcept; // not always defined
iterator find(const Address & addr) const noexcept;
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Specializations of basic_address_range satisfy the requirements for Destructible (C++ 2014, 17.6.3.1),
CopyConstructible (C++ 2014, 17.6.3.1), and CopyAssignable (C++ 2014, 17.6.3.1).
basic_address_range() noexcept;
3 Effects: Constructs an object of type basic_address_range<Address > that represents an empty range.
ISO/IEC TS 19216:2018(E)
class network_v4
{
public:
// 21.11.1, constructors:
constexpr network_v4() noexcept;
constexpr network_v4(const address_v4& addr, int prefix_len);
constexpr network_v4(const address_v4& addr, const address_v4& mask);
// 21.11.2, members:
constexpr address_v4 address() const noexcept;
constexpr int prefix_length() const noexcept;
constexpr address_v4 netmask() const noexcept;
constexpr address_v4 network() const noexcept;
constexpr address_v4 broadcast() const noexcept;
address_v4_range hosts() const noexcept;
constexpr network_v4 canonical() const noexcept;
constexpr bool is_host() const noexcept;
constexpr bool is_subnet_of(const network_v4& other) const noexcept;
template<class Allocator = allocator<char>>
basic_string<char, char_traits<char>, Allocator>
to_string(const Allocator& a = Allocator()) const;
};
ISO/IEC TS 19216:2018(E)
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 network_v4 satisfies the requirements for Destructible (C++ 2014, 17.6.3.1), CopyConstructible (C++
2014, 17.6.3.1), and CopyAssignable (C++ 2014, 17.6.3.1).
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
3 Returns: If str contains a value of the form address ’/’ prefix-length, a network_v4 object constructed
with the result of applying make_address_v4() to the address portion of the string, and the result of
converting prefix-length to an integer of type int. Otherwise returns network_v4() and sets ec to
reflect the error.
4 Error conditions:
(4.1) — errc::invalid_argument — if str is not a valid textual representation of an IPv4 address and
prefix length.
class network_v6
{
public:
// 21.12.1, constructors:
constexpr network_v6() noexcept;
constexpr network_v6(const address_v6& addr, int prefix_len);
// 21.12.2, members:
constexpr address_v6 address() const noexcept;
constexpr int prefix_length() const noexcept;
constexpr address_v6 network() const noexcept;
address_v6_range hosts() const noexcept;
constexpr network_v6 canonical() const noexcept;
constexpr bool is_host() const noexcept;
constexpr bool is_subnet_of(const network_v6& other) const noexcept;
template<class Allocator = allocator<char>>
basic_string<char, char_traits<char>, Allocator>
to_string(const Allocator& a = Allocator()) const;
};
ISO/IEC TS 19216:2018(E)
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 network_v6 satisfies the requirements for Destructible (C++ 2014, 17.6.3.1), CopyConstructible (C++
2014, 17.6.3.1), and CopyAssignable (C++ 2014, 17.6.3.1).
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
namespace ip {
template<class InternetProtocol>
class basic_endpoint
{
public:
// types:
using protocol_type = InternetProtocol;
// 21.13.1, constructors:
constexpr basic_endpoint() noexcept;
constexpr basic_endpoint(const protocol_type& proto,
port_type port_num) noexcept;
constexpr basic_endpoint(const ip::address& addr,
port_type port_num) noexcept;
// 21.13.2, members:
constexpr protocol_type protocol() const noexcept;
constexpr ip::address address() const noexcept;
void address(const ip::address& addr) noexcept;
constexpr port_type port() const noexcept;
void port(port_type port_num) noexcept;
};
} // namespace ip
ISO/IEC TS 19216:2018(E)
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 Instances of the basic_endpoint class template meet the requirements for an Endpoint (18.2.4).
3 Extensible implementations provide the following member functions:
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
namespace ip {
template<class InternetProtocol>
class basic_endpoint
{
public:
void* data() noexcept;
const void* data() const noexcept;
constexpr size_t size() const noexcept;
void resize(size_t s);
constexpr size_t capacity() const noexcept;
// remainder unchanged
private:
union
{
sockaddr_in v4_;
sockaddr_in6 v6_;
} data_; // exposition only
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
template<class InternetProtocol>
constexpr bool operator!=(const basic_endpoint<InternetProtocol>& a,
const basic_endpoint<InternetProtocol>& b) noexcept;
2 Returns: !(a == b).
template<class InternetProtocol>
constexpr bool operator< (const basic_endpoint<InternetProtocol>& a,
const basic_endpoint<InternetProtocol>& b) noexcept;
3 Returns: tie(a.address(), a.port()) < tie(b.address(), b.port()).
template<class InternetProtocol>
constexpr bool operator> (const basic_endpoint<InternetProtocol>& a,
const basic_endpoint<InternetProtocol>& b) noexcept;
4 Returns: b < a.
template<class InternetProtocol>
constexpr bool operator<=(const basic_endpoint<InternetProtocol>& a,
const basic_endpoint<InternetProtocol>& b) noexcept;
5 Returns: !(b < a).
template<class InternetProtocol>
constexpr bool operator>=(const basic_endpoint<InternetProtocol>& a,
const basic_endpoint<InternetProtocol>& b) noexcept;
6 Returns: !(a < b).
ISO/IEC TS 19216:2018(E)
2 Returns: os.
3 [ Note: The representation of the endpoint when it contains an IP version 6 address is based on [RFC2732].
— end note ]
ISO/IEC TS 19216:2018(E)
template<class InternetProtocol>
class basic_resolver_entry
{
public:
// types:
using protocol_type = InternetProtocol;
using endpoint_type = typename InternetProtocol::endpoint;
// 21.14.1, constructors:
basic_resolver_entry();
basic_resolver_entry(const endpoint_type& ep,
string_view h,
string_view s);
// 21.14.2, members:
endpoint_type endpoint() const;
operator endpoint_type() const;
template<class Allocator = allocator<char>>
basic_string<char, char_traits<char>, Allocator>
host_name(const Allocator& a = Allocator()) const;
template<class Allocator = allocator<char>>
basic_string<char, char_traits<char>, Allocator>
service_name(const Allocator& a = Allocator()) const;
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
template<class InternetProtocol>
bool operator!=(const basic_resolver_entry<InternetProtocol>& a,
const basic_resolver_entry<InternetProtocol>& b);
2 Returns: !(a == b).
template<class InternetProtocol>
class basic_resolver_results
{
public:
// types:
using protocol_type = InternetProtocol;
using endpoint_type = typename protocol_type::endpoint;
using value_type = basic_resolver_entry<protocol_type>;
using const_reference = const value_type&;
ISO/IEC TS 19216:2018(E)
// 21.15.5, swap:
void swap(basic_resolver_results& that) noexcept;
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 The class template basic_resolver_results satisfies the requirements of a sequence container (C++ 2014,
23.2.3), except that only the operations defined for const-qualified sequence containers are supported. The
class template basic_resolver_results supports forward iterators.
3 A default-constructed basic_resolver_results object is empty. A non-empty results object is obtained
only by calling a basic_resolver object’s wait or async_wait operations, or otherwise by copy construction,
move construction, assignment, or swap from another non-empty results object.
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
template<class InternetProtocol>
bool operator!=(const basic_resolver_results<InternetProtocol>& a,
const basic_resolver_results<InternetProtocol>& b);
2 Returns: !(a == b).
class resolver_base
{
public:
using flags = T1 ;
static const flags passive;
static const flags canonical_name;
static const flags numeric_host;
static const flags numeric_service;
static const flags v4_mapped;
static const flags all_matching;
static const flags address_configured;
protected:
resolver_base();
~resolver_base();
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
1 resolver_base defines a bitmask type, flags, with the bitmask elements shown in Table 37.
ISO/IEC TS 19216:2018(E)
template<class InternetProtocol>
class basic_resolver : public resolver_base
{
public:
// types:
~basic_resolver();
basic_resolver& operator=(const basic_resolver&) = delete;
basic_resolver& operator=(basic_resolver&& rhs);
ISO/IEC TS 19216:2018(E)
void cancel();
template<class CompletionToken>
DEDUCED async_resolve(string_view host_name, string_view service_name,
CompletionToken&& token);
template<class CompletionToken>
DEDUCED async_resolve(string_view host_name, string_view service_name,
flags f, CompletionToken&& token);
template<class CompletionToken>
DEDUCED async_resolve(const protocol_type& protocol,
string_view host_name, string_view service_name,
CompletionToken&& token);
template<class CompletionToken>
DEDUCED async_resolve(const protocol_type& protocol,
string_view host_name, string_view service_name,
flags f, CompletionToken&& token);
template<class CompletionToken>
DEDUCED async_resolve(const endpoint_type& e,
CompletionToken&& token);
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
void cancel();
2 Effects: Cancels all outstanding asynchronous resolve operations associated with *this. Completion
handlers for canceled operations are passed an error code ec such that ec == errc::operation_-
canceled yields true.
3 Remarks: Does not block (C++ 2014, 17.3.2) the calling thread pending completion of the canceled
operations.
ISO/IEC TS 19216:2018(E)
addrinfo hints;
hints.ai_flags = static_cast<int>(f);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = endpoint_type().protocol().type();
hints.ai_protocol = endpoint_type().protocol().protocol();
hints.ai_addr = nullptr;
hints.ai_addrlen = 0;
hints.ai_canonname = nullptr;
hints.ai_next = nullptr;
addrinfo* result = nullptr;
getaddrinfo(H, S, &hints, &result);
6 Returns: On success, a non-empty results object containing the results of the resolve operation.
Otherwise results_type().
template<class CompletionToken>
DEDUCED async_resolve(string_view host_name, string_view service_name,
CompletionToken&& token);
7 Returns:
async_resolve(host_name, service_name, resolver_base::flags(),
forward<CompletionToken>(token))
template<class CompletionToken>
DEDUCED async_resolve(string_view host_name, string_view service_name,
flags f, CompletionToken&& token);
8 Completion signature: void(error_code ec, results_type r).
9 Effects: If host_name.data() != nullptr, let H be an ntbs constructed from host_name; otherwise,
let H be nullptr. If service_name.data() != nullptr, let S be an ntbs constructed from service_-
name; otherwise, let S be nullptr. Initiates an asynchronous operation to resolve a host name and
service name, as if by POSIX:
addrinfo hints;
hints.ai_flags = static_cast<int>(f);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = endpoint_type().protocol().type();
hints.ai_protocol = endpoint_type().protocol().protocol();
hints.ai_addr = nullptr;
hints.ai_addrlen = 0;
hints.ai_canonname = nullptr;
hints.ai_next = nullptr;
addrinfo* result = nullptr;
getaddrinfo(H, S, &hints, &result);
On success, r is a non-empty results object containing the results of the resolve operation. Otherwise,
r is results_type().
ISO/IEC TS 19216:2018(E)
12 Returns: On success, a non-empty results object containing the results of the resolve operation.
Otherwise results_type().
template<class CompletionToken>
DEDUCED async_resolve(const protocol_type& protocol,
string_view host_name, string_view service_name,
CompletionToken&& token);
13 Returns:
async_resolve(protocol, host_name, service_name, resolver_base::flags(),
forward<CompletionToken>(token))
template<class CompletionToken>
DEDUCED async_resolve(const protocol& protocol,
string_view host_name, string_view service_name,
flags f, CompletionToken&& token);
14 Completion signature: void(error_code ec, results_type r).
15 Effects: If host_name.data() != nullptr, let H be an ntbs constructed from host_name; otherwise,
let H be nullptr. If service_name.data() != nullptr, let S be an ntbs constructed from service_-
name; otherwise, let S be nullptr. Initiates an asynchronous operation to resolve a host name and
service name, as if by POSIX:
addrinfo hints;
hints.ai_flags = static_cast<int>(f);
hints.ai_family = protocol.family();
hints.ai_socktype = protocol.type();
hints.ai_protocol = protocol.protocol();
hints.ai_addr = nullptr;
hints.ai_addrlen = 0;
hints.ai_canonname = nullptr;
hints.ai_next = nullptr;
addrinfo* result = nullptr;
getaddrinfo(H, S, &hints, &result);
ISO/IEC TS 19216:2018(E)
On success, r is a non-empty results object containing the results of the resolve operation. Otherwise,
r is results_type().
17 Returns: On success, a results object with size() == 1 containing the results of the resolve operation.
Otherwise results_type().
template<class CompletionToken>
DEDUCED async_resolve(const endpoint_type& e,
CompletionToken&& token);
18 Completion signature: void(error_code ec, results_type r).
19 Effects: Let S1 and S2 be implementation-defined values that are sufficiently large to hold the host
name and service name respectively. Initiates an asynchronous operation to resolve an endpoint as if
by POSIX:
char host_name[S1];
char service_name[S2];
int flags = 0;
if (endpoint_type().protocol().type() == SOCK_DGRAM)
flags |= NI_DGRAM;
int result = getnameinfo((const sockaddr*)e.data(), e.size(),
host_name, S1,
service_name, S2,
flags);
if (result != 0)
{
flags |= NI_NUMERICSERV;
result = getnameinfo((const sockaddr*)e.data(), e.size(),
host_name, S1,
service_name, S2,
flags);
}
ISO/IEC TS 19216:2018(E)
On success, r is a results object with size() == 1 containing the results of the resolve operation;
otherwise, r is results_type().
class tcp
{
public:
// types:
using endpoint = basic_endpoint<tcp>;
using resolver = basic_resolver<tcp>;
using socket = basic_stream_socket<tcp>;
using acceptor = basic_socket_acceptor<tcp>;
using iostream = basic_socket_iostream<tcp>;
class no_delay;
// static members:
static constexpr tcp v4() noexcept;
static constexpr tcp v6() noexcept;
tcp() = delete;
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
ISO/IEC TS 19216:2018(E)
class tcp
{
public:
constexpr int family() const noexcept;
constexpr int type() const noexcept;
constexpr int protocol() const noexcept;
// remainder unchanged
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
4 The return values for these member functions are listed in Table 38.
5 [ Note: The constants AF_INET, AF_INET6 and SOCK_STREAM are defined in the POSIX <sys/socket.h>
header. The constant IPPROTO_TCP is defined in the POSIX <netinet/in.h> header. — end note ]
ISO/IEC TS 19216:2018(E)
class udp
{
public:
// types:
using endpoint = basic_endpoint<udp>;
using resolver = basic_resolver<udp>;
using socket = basic_datagram_socket<udp>;
// static members:
static constexpr udp v4() noexcept;
static constexpr udp v6() noexcept;
udp() = delete;
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
class udp
{
public:
constexpr int family() const noexcept;
constexpr int type() const noexcept;
constexpr int protocol() const noexcept;
// remainder unchanged
};
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
4 The return values for these member functions are listed in Table 39.
ISO/IEC TS 19216:2018(E)
5 [ Note: The constants AF_INET, AF_INET6 and SOCK_DGRAM are defined in the POSIX <sys/socket.h> header.
The constant IPPROTO_UDP is defined in the POSIX <netinet/in.h> header. — end note ]
C L N T Requirements,
definition or notes
ip::tcp:: IPPROTO_TCP TCP_NODELAY int Satisfies the
no_delay BooleanSocket-
Option (18.2.10) type
requirements.
Determines whether a
TCP socket will avoid
coalescing of small
segments. [ Note:
That is, setting this
option disables the
Nagle algorithm.
— end note ]
ISO/IEC TS 19216:2018(E)
C L N T Requirements,
definition or notes
ip::v6_only IPPROTO_IPV6 IPV6_V6ONLY int Satisfies the
BooleanSocket-
Option (18.2.10) type
requirements.
Determines whether a
socket created for an
IPv6 protocol is
restricted to IPv6
communications only.
Implementations are
not required to
support setting the
v6_only option to
false, and the initial
value of the v6_only
option for a socket is
implementation-
defined. [ Note: As not
all operating systems
support dual stack IP
networking. Some
operating systems that
do provide dual stack
support offer a
configuration option to
disable it or to set the
initial value of the
v6_only socket option.
— end note ]
ip::unicast:: IPPROTO_IPV6 if F IPV6_UNICAST_- int Satisfies the
hops == AF_INET6, HOPS if F == IntegerSocket-
otherwise AF_INET6, Option (18.2.11) type
IPPROTO_IP otherwise IP_TTL requirements. Specifies
the default number of
hops (also known as
time-to-live or TTL)
on outbound
datagrams. The
constructor and
assignment operator
for the
ip::unicast::hops
class throw
out_of_range if the
int argument is not in
the range [0, 255].
ISO/IEC TS 19216:2018(E)
C L N T Requirements,
definition or notes
ip::multicast:: IPPROTO_IPV6 if F IPV6_JOIN_GROUP ipv6_mreq if F Satisfies the
join_group == AF_INET6, if F == AF_INET6, == AF_INET6, MulticastGroupSock-
otherwise otherwise IP_- otherwise etOption (21.2.2)
IPPROTO_IP ADD_MEMBERSHIP ip_mreq type requirements.
Requests that the
socket join the
specified multicast
group.
ip::multicast:: IPPROTO_IPV6 if F IPV6_LEAVE_- ipv6_mreq if F Satisfies the
leave_group == AF_INET6, GROUP if F == == AF_INET6, MulticastGroupSock-
otherwise AF_INET6, otherwise etOption (21.2.2)
IPPROTO_IP otherwise IP_- ip_mreq type requirements.
DROP_MEMBERSHIP Requests that the
socket leave the
specified multicast
group.
ip::multicast:: IPPROTO_IPV6 if F IPV6_- unsigned int if Specifies the network
outbound_- == AF_INET6, MULTICAST_IF if F == AF_INET6, interface to use for
interface otherwise F == AF_INET6, otherwise outgoing multicast
(21.21.1) IPPROTO_IP otherwise in_addr datagrams.
IP_MULTICAST_IF
ip::multicast:: IPPROTO_IPV6 if F IPV6_- int Satisfies the
hops == AF_INET6, MULTICAST_HOPS IntegerSocket-
otherwise if F == AF_INET6, Option (18.2.11) type
IPPROTO_IP otherwise IP_- requirements. Specifies
MULTICAST_TTL the default number of
hops (also known as
time-to-live or TTL)
on outbound
datagrams. The
constructor and
assignment operator
for the
ip::multicast::hops
class throw
out_of_range if the
int argument is not in
the range [0, 255].
ip::multicast:: IPPROTO_IPV6 if F IPV6_- int Satisfies the
enable_- == AF_INET6, MULTICAST_LOOP BooleanSocket-
loopback otherwise if F == AF_INET6, Option (18.2.10) type
IPPROTO_IP otherwise IP_- requirements.
MULTICAST_LOOP Determines whether
multicast datagrams
are delivered back to
the local application.
ISO/IEC TS 19216:2018(E)
class outbound_interface
{
public:
// constructors:
explicit outbound_interface(const address_v4& network_interface) noexcept;
explicit outbound_interface(unsigned int network_interface) noexcept;
};
} // namespace multicast
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std
2 outbound_interface satisfies the requirements for Destructible (C++ 2014, 17.6.3.1), CopyConstructible
(C++ 2014, 17.6.3.1), CopyAssignable (C++ 2014, 17.6.3.1), and SettableSocketOption (18.2.9).
3 Extensible implementations provide the following member functions:
namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
namespace ip {
namespace multicast {
class outbound_interface
{
public:
template<class Protocol> int level(const Protocol& p) const noexcept;
template<class Protocol> int name(const Protocol& p) const noexcept;
template<class Protocol> const void* data(const Protocol& p) const noexcept;
template<class Protocol> size_t size(const Protocol& p) const noexcept;
// remainder unchanged
private:
in_addr v4_value_; // exposition only
unsigned int v6_value_; // exposition only
};
} // namespace multicast
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
ISO/IEC TS 19216:2018(E)
} // namespace std
ISO/IEC TS 19216:2018(E)
Index
Acceptable, 109 MulticastGroupSocketOption, 172
associated executor, 25 outbound_interface, 217
associated_allocator Protocol, 109
specialization for executor_binder, 39 tcp, 212
associated_executor udp, 213
specialization for executor_binder, 39
associator, 22 GettableSocketOption, 110
async_result
specialization for executor_binder, 38 host byte order, 3
specialization for packaged_task, 59
initiating function, 24
specialization for use_future_t, 58
deduction of return type, 24
asynchronous operation, 3, 81
lifetime of arguments, 25
asynchronous socket operations, 107
non-blocking requirements, 25
asynchronous wait operation, 71
production of return value, 24
AsyncReadStream, 92
IntegerSocketOption, 113
AsyncWriteStream, 93
InternetProtocol, 171
basic_endpoint IoControlCommand, 115
extensible implementation, 197
linger
BooleanSocketOption, 111
extensible implementation, 120
extensible implementation, 112, 114
MulticastGroupSocketOption, 172
completion handler, 24
extensible implementation, 172
completion signature, 24
mutable buffer sequence, 78
completion token, 24
CompletionCondition, 94 native handles, 107
composed asynchronous operation, 27 network byte order, 3
ConnectCondition, 115
constant buffer sequence, 79 orderly shutdown, 92
outbound_interface
definitions, 3 extensible implementation, 217
dynamic buffer, 80 outstanding work, 26, 62
Endpoint, 107 Protocol, 109
extensible implementation, 108 extensible implementation, 109
EndpointSequence, 108
error codes read operation, 81
resolver, 173 requirements
socket, 115 associated_allocator specializations, 29
stream, 82 associated_executor specializations, 35
ExecutionContext, 21 associator, 22
extensible implementation async_result specializations, 28
basic_endpoint, 197 AsyncReadStream, 92
BooleanSocketOption, 112, 114 AsyncWriteStream, 93
Endpoint, 108 CompletionCondition, 94
linger, 120 ConnectCondition, 115
ISO/IEC TS 19216:2018(E)
ConstBufferSequence, 79
DynamicBuffer, 80
ExecutionContext, 21
InternetProtocol, 171
IoControlCommand, 115
MulticastGroupSocketOption, 172
MutableBufferSequence, 78
signature, 22
SyncReadStream, 92
SyncWriteStream, 93
WaitTraits, 68
run functions, 62
service, 22
SettableSocketOption, 111
signature requirements, 22
socket operations
asynchronous, 107
synchronous, 106
socket options, 118
synchronous operation, 3
synchronous socket operations, 106
SyncReadStream, 92
SyncWriteStream, 93
target
executor, 46
tcp
extensible implementation, 212
udp
extensible implementation, 213
uses-executor construction, 34
write operation, 81
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
on_work_started, 48 has_service, 32
operator bool, 48 host_name, 211
operator!=, 49
operator=, 47 io_context, 61
operator==, 49 constructor, 62
post, 48 count_type, 62
swap, 47, 49 get_executor, 62
target, 48 poll, 64
target_type, 48 poll_one, 64
executor_arg, 33 restart, 64
executor_arg_t, 33 run, 62
executor_binder, 36 run_for, 63
constructor, 37 run_one, 63
get, 38 run_one_for, 63
get_executor, 38 run_one_until, 63
operator(), 38 run_until, 63
executor_work_guard, 40 stop, 64
constructor, 41 stopped, 64
destructor, 41 io_context::executor_type, 65
get_executor, 41 constructor, 65
owns_work, 41 context, 66
reset, 41 defer, 66
<experimental/buffer>, 73 dispatch, 66
<experimental/executor>, 16 on_work_finished, 66
<experimental/internet>, 167 on_work_started, 66
<experimental/io_context>, 61 operator!=, 66
<experimental/net>, 13 operator=, 66
<experimental/netfwd>, 14 operator==, 66
<experimental/socket>, 104 post, 66
<experimental/timer>, 67 running_in_this_thread, 66
expires_after is_const_buffer_sequence, 84
basic_waitable_timer, 71 is_const_buffer_sequence_v, 73
expires_at is_dynamic_buffer, 84
basic_waitable_timer, 71 is_dynamic_buffer_v, 73
expiry is_executor, 33
basic_waitable_timer, 71 is_executor_v, 16
is_link_local
get address_v6, 184
executor_binder, 38 is_loopback
get_allocator address, 176
use_future_t, 57 address_v4, 179
get_associated_allocator, 30 address_v6, 184
get_associated_executor, 35 is_multicast
get_executor, 92, 93 address, 176
basic_waitable_timer, 71 address_v4, 179
executor_binder, 38 address_v6, 184
executor_work_guard, 41 is_multicast_global
io_context, 62 address_v6, 185
system_context, 44 is_multicast_link_local
get_inner_executor address_v6, 184
strand, 55 is_multicast_node_local
ISO/IEC TS 19216:2018(E)
ISO/IEC TS 19216:2018(E)
system_executor, 43 io_context, 63
operator> run_until
address, 176 io_context, 63
address_v4, 180 running_in_this_thread
address_v6, 185 io_context::executor_type, 66
operator>= strand, 55
address, 177
address_v4, 180 scope_id
address_v6, 185 address_v6, 183
outbound_interface, 217 scope_id_type, 167
owns_work shutdown
executor_work_guard, 41 execution_context, 31
size
poll const_buffer, 84
io_context, 64 dynamic_string_buffer, 90
poll_one dynamic_vector_buffer, 89
io_context, 64 mutable_buffer, 83
port_type, 167 socket_base, 116
post, 50 socket_category, 115
executor, 48 socket_errc, 104
io_context::executor_type, 66 make_error_code, 116
strand, 56 make_error_condition, 116
system_executor, 43 stop
prepare io_context, 64
dynamic_string_buffer, 91 system_context, 44
dynamic_vector_buffer, 89 stopped
io_context, 64
read, 96, 97 system_context, 44
read_some, 92 strand, 52
read_until, 102 constructor, 54
rebind context, 56
use_future_t, 57 defer, 56
reset destructor, 55
executor_work_guard, 41 dispatch, 56
resolve_base, 204 get_inner_executor, 55
resolver_base, 204 on_work_finished, 56
resolver_category, 173 on_work_started, 56
resolver_errc, 167 operator!=, 56
make_error_code, 174 operator=, 55
make_error_condition, 174 operator==, 56
restart post, 56
io_context, 64 running_in_this_thread, 55
run stream_category, 82
io_context, 62 stream_errc, 73
run_for make_error_code, 82
io_context, 63 make_error_condition, 82
run_one swap
io_context, 63 executor, 47, 49
run_one_for system_context, 43
io_context, 63 destructor, 44
run_one_until get_executor, 44
ISO/IEC TS 19216:2018(E)
target
executor, 48
target_type
executor, 48
tcp, 211
to_bytes
address_v4, 180
address_v6, 185
to_string
address, 176
address_v4, 180
address_v6, 185
to_uint
address_v4, 180
to_v4
address, 176
to_v6
address, 176
to_wait_duration
wait_traits, 68, 69
transfer_all, 94
transfer_at_least, 95
transfer_exactly, 95
udp, 212
use_future_t, 56
constructor, 57
get_allocator, 57
operator(), 57
rebind, 57
use_service, 32
uses_executor, 34
uses_executor_v, 16
v4_mapped, 167
v4_mapped_t, 167
wait
basic_waitable_timer, 71
wait_traits, 68
ISO/IEC TS 19216:2018(E)
Buying standards PLUS is an updating service exclusive to BSI Subscribing Members. You will
automatically receive the latest hard copy of your standards when they’re
You can buy and download PDF versions of BSI publications, including British revised or replaced.
and adopted European and international standards, through our website at
bsigroup.com/shop, where hard copies can also be purchased. To find out more about becoming a BSI Subscribing Member and the benefits
of membership, please visit bsigroup.com/shop.
If you need international and foreign standards from other Standards Development
Organizations, hard copies can be ordered from our Customer Services team. With a Multi-User Network Licence (MUNL) you are able to host standards
publications on your intranet. Licences can cover as few or as many users as you
Copyright in BSI publications wish. With updates supplied as soon as they’re available, you can be sure your
documentation is current. For further information, email [email protected].
All the content in BSI publications, including British Standards, is the property
of and copyrighted by BSI or some person or entity that owns copyright in the Revisions
information used (such as the international standardization bodies) and has
formally licensed such information to BSI for commercial publication and use. Our British Standards and other publications are updated by amendment or revision.
Save for the provisions below, you may not transfer, share or disseminate any We continually improve the quality of our products and services to benefit your
portion of the standard to any other person. You may not adapt, distribute, business. If you find an inaccuracy or ambiguity within a British Standard or other
commercially exploit, or publicly display the standard or any portion thereof in any BSI publication please inform the Knowledge Centre.
manner whatsoever without BSI’s prior written consent.
Useful Contacts
Storing and using standards Customer Services
Standards purchased in soft copy format: Tel: +44 345 086 9001
• A British Standard purchased in soft copy format is licensed to a sole named Email (orders): [email protected]
user for personal or internal company use only. Email (enquiries): [email protected]
• The standard may be stored on more than 1 device provided that it is accessible Subscriptions
by the sole named user only and that only 1 copy is accessed at any one time. Tel: +44 345 086 9001
• A single paper copy may be printed for personal or internal company use only. Email: [email protected]
• Standards purchased in hard copy format:
Knowledge Centre
• A British Standard purchased in hard copy format is for personal or internal Tel: +44 20 8996 7004
company use only.
Email: [email protected]
• It may not be further reproduced – in any format – to create an additional copy.
This includes scanning of the document. Copyright & Licensing
If you need more than 1 copy of the document, or if you wish to share the Tel: +44 20 8996 7070
document on an internal network, you can save money by choosing a subscription Email: [email protected]
product (see ‘Subscriptions’).
BSI Group Headquarters
389 Chiswick High Road London W4 4AL UK