List of Tables [tab]


7 Feature test macros (Informative) [feature.test]

Table 1 — Feature-test macro(s)
Macro nameValue
__cpp_lib_experimental_net 201803
__cpp_lib_experimental_net_extensible 201803

10 Library summary [summary]

Table 2 — Networking library summary
ClauseHeader(s)
Convenience header ([convenience.hdr]) <experimental/net>
Forward declarations ([fwd.decl]) <experimental/netfwd>
Asynchronous model ([async]) <experimental/executor>
Basic I/O services ([io_context]) <experimental/io_context>
Timers ([timer]) <experimental/timer>
Buffers ([buffer]) <experimental/buffer>
Buffer-oriented streams ([buffer.stream])
Sockets ([socket]) <experimental/socket>
Socket iostreams ([socket.iostreams])
Socket algorithms ([socket.algo])
Internet protocol ([internet]) <experimental/internet>

10 Library summary [summary]

Table 3 — Template parameters and type requirements
template parameter nametype requirements
AcceptableProtocol acceptable protocol ([socket.reqmts.acceptableprotocol])
Allocator C++ 2014 [allocator.requirements]
AsyncReadStream buffer-oriented asynchronous read stream ([buffer.stream.reqmts.asyncreadstream])
AsyncWriteStream buffer-oriented asynchronous write stream ([buffer.stream.reqmts.asyncwritestream])
Clock C++ 2014 [time.clock.req]
CompletionCondition completion condition ([buffer.stream.reqmts.completioncondition])
CompletionToken completion token ([async.reqmts.async.token])
ConnectCondition connect condition ([socket.reqmts.connectcondition])
ConstBufferSequence constant buffer sequence ([buffer.reqmts.constbuffersequence])
DynamicBuffer dynamic buffer ([buffer.reqmts.dynamicbuffer])
EndpointSequence endpoint sequence ([socket.reqmts.endpointsequence])
ExecutionContext execution context ([async.reqmts.executioncontext])
Executor executor ([async.reqmts.executor])
GettableSocketOption gettable socket option ([socket.reqmts.gettablesocketoption])
InternetProtocol Internet protocol ([internet.reqmts.protocol])
IoControlCommand I/O control command ([socket.reqmts.iocontrolcommand])
MutableBufferSequence mutable buffer sequence ([buffer.reqmts.mutablebuffersequence])
ProtoAllocator proto-allocator ([async.reqmts.proto.allocator])
Protocol protocol ([socket.reqmts.protocol])
Service service ([async.reqmts.service])
SettableSocketOption settable socket option ([socket.reqmts.settablesocketoption])
Signature signature ([async.reqmts.signature])
SyncReadStream buffer-oriented synchronous read stream ([buffer.stream.reqmts.syncreadstream])
SyncWriteStream buffer-oriented synchronous write stream ([buffer.stream.reqmts.syncwritestream])
WaitTraits wait traits ([timer.reqmts.waittraits])

13.2.2 Executor requirements [async.reqmts.executor]

Table 4 — Executor requirements
expressiontypeassertion/note pre/post-conditions
X u(x1); Shall not exit via an exception.
post: u == x1 and std::addressof(u.context()) == std::addressof(x1.context()).
X u(mx1); Shall not exit via an exception.
post: u equals the prior value of mx1 and std::addressof(u.context()) equals the prior value of std::addressof(mx1.context()).
x1 == x2 bool Returns true only if x1 and x2 can be interchanged with identical effects in any of the expressions defined in these type requirements. [ Note: Returning false does not necessarily imply that the effects are not identical.  — end note ]
operator== shall be reflexive, symmetric, and transitive, and shall not exit via an exception.
x1 != x2 bool Same as !(x1 == x2).
x1.context() execution_context&, or E& where E is a type that satisfies the ExecutionContext ([async.reqmts.executioncontext]) requirements. Shall not exit via an exception. The comparison operators and member functions defined in these requirements shall not alter the reference returned by this function.
x1.on_work_started() Shall not exit via an exception.
x1.on_work_finished() Shall not exit via an exception.
Precondition: A preceding call x2.on_work_started() where x1 == x2.
x1.dispatch(
std::move(f), a)
Effects: Creates an object f1 initialized with DECAY_COPY(std::forward<Func>(f)) (C++ 2014 [thread.decaycopy]) in the current thread of execution. Calls f1() at most once. The executor may block forward progress of the caller until f1() finishes execution. Executor implementations should use the supplied allocator to allocate any memory required to store the function object. Prior to invoking the function object, the executor shall deallocate any memory allocated. [ Note: Executors defined in this document always use the supplied allocator unless otherwise specified.  — end note ]
Synchronization: The invocation of dispatch synchronizes with (C++ 2014 [intro.multithread]) the invocation of f1.
x1.post(std::move(f), a) Effects: Creates an object f1 initialized with DECAY_COPY(std::forward<Func>(f)) in the current thread of execution. Calls f1() at most once. The executor shall not block forward progress of the caller pending completion of f1(). The executor may begin f1's progress before the call to post completes. Executor implementations should use the supplied allocator to allocate any memory required to store the function object. Prior to invoking the function object, the executor shall deallocate any memory allocated. [ Note: Executors defined in this document always use the supplied allocator unless otherwise specified.  — end note ]
Synchronization: The invocation of post synchronizes with (C++ 2014 [intro.multithread]) the invocation of f1.
x1.defer(std::move(f), a) Effects: Creates an object f1 initialized with DECAY_COPY(std::forward<Func>(f)) in the current thread of execution. Calls f1() at most once. The executor shall not block forward progress of the caller pending completion of f1(). The executor should not begin f1's progress before the call to defer completes. [ Note: One use of defer is to convey the intention of the caller that f1 is a continuation of the current call context. The executor can use this information to optimize or otherwise adjust the way in which f1 is invoked.  — end note ] Executor implementations should use the supplied allocator to allocate any memory required to store the function object. Prior to invoking the function object, the executor shall deallocate any memory allocated. [ Note: Executors defined in this document always use the supplied allocator unless otherwise specified.  — end note ]
Synchronization: The invocation of defer synchronizes with (C++ 2014 [intro.multithread]) the invocation of f1.

13.2.3 Execution context requirements [async.reqmts.executioncontext]

Table 5 — ExecutionContext requirements
expressionreturn typeassertion/note pre/post-condition
X::executor_type type meeting Executor ([async.reqmts.executor]) requirements
x.~X() Destroys all unexecuted function objects that were submitted via an executor object that is associated with the execution context.
x.get_executor() X::executor_type Returns an executor object that is associated with the execution context.

13.2.6 Associator requirements [async.reqmts.associator]

Table 6 — Associator requirements
expressionreturn typeassertion/note pre/post-conditions
X<S>::type X<S, D>::type
X<S, C>::type The associated type.
X<S>::get(s) X<S>::type Returns X<S>::get(S, d).
X<S, C>::get(s, c) X<S, C>::type Returns the associated object.

13.3 Class template async_result [async.async.result]

Table 7async_result specialization requirements
ExpressionReturn typeRequirement
R::completion_handler_type A type satisfying MoveConstructible requirements (C++ 2014 [moveconstructible]), An object of type completion_handler_type shall be a function object with call signature Signature, and completion_handler_type shall be constructible with an rvalue of type CompletionToken.
R::return_type void; or a type satisfying MoveConstructible requirements (C++ 2014 [moveconstructible])
R r(h);
r.get() R::return_type Note: An asynchronous operation's initiating function uses the get() member function as the sole operand of a return statement.  — end note ]

13.5 Class template associated_allocator [async.assoc.alloc]

Table 8associated_allocator specialization requirements
ExpressionReturn typeNote
typename X::type A type meeting the proto-allocator ([async.reqmts.proto.allocator]) requirements.
X::get(t) X::type Shall not exit via an exception. Equivalent to X::get(t, ProtoAllocator()).
X::get(t, a) X::type Shall not exit via an exception.

13.12 Class template associated_executor [async.assoc.exec]

Table 9associated_executor specialization requirements
ExpressionReturn typeNote
typename X::type A type meeting Executor requirements ([async.reqmts.executor]).
X::get(t) X::type Shall not exit via an exception. Equivalent to X::get(t, Executor()).
X::get(t, e) X::type Shall not exit via an exception.

13.26.3 Partial class template specialization async_result for use_future_t [async.use.future.result]

Table 10async_result<use_future_t<ProtoAllocator>, Result(Args...)> semantics
NU0R::return_typeF::operator() effects
0 future<void> None.
1 error_code future<void> If a0 evaluates to true, atomically stores the exception pointer produced by make_exception_ptr(system_error(a0)) in the shared state.
1 exception_ptr future<void> If a0 is non-null, atomically stores the exception pointer a0 in the shared state.
1 all other types future<U0> Atomically stores forward<A0>(a0) in the shared state.
2 error_code future<U1> If a0 evaluates to true, atomically stores the exception pointer produced by make_exception_ptr(system_error(a0)) in the shared state; otherwise, atomically stores forward<A1>(a1) in the shared state.
2 exception_ptr future<U1> If a0 is non-null, atomically stores the exception pointer in the shared state; otherwise, atomically stores forward<A1>(a1) in the shared state.
2 all other types future<tuple<U0, U1>> Atomically stores forward_as_tuple(
forward<A0>(a0), forward<A1>(a1))
in the shared state.
>2 error_code future<tuple<U1, , UN-1>> If a0 evaluates to true, atomically stores the exception pointer produced by make_exception_ptr(system_error(a0)) in the shared state; otherwise, atomically stores forward_as_tuple(forward<A1>(a1), , forward<AN-1>(aN-1)) in the shared state.
>2 exception_ptr future<tuple<U1, , UN-1>> If a0 is non-null, atomically stores the exception pointer in the shared state; otherwise, atomically stores forward_as_tuple(forward<A1>(a1), , forward<AN-1>(aN-1)) in the shared state.
>2 all other types future<tuple<U0, , UN-1>> Atomically stores forward_as_tuple(
forward<A0>(a0), , forward<AN-1>(aN-1))
in the shared state.

15.2.1 Wait traits requirements [timer.reqmts.waittraits]

Table 11 — WaitTraits requirements
expressionreturn typeassertion/note pre/post-condition
X::to_wait_duration(d) Clock::duration Returns a Clock::duration value to be used in a wait or async_wait operation. [ Note: The return value is typically representative of the duration d.  — end note ]
X::to_wait_duration(t) Clock::duration Returns a Clock::duration value to be used in a wait or async_wait operation. [ Note: The return value is typically representative of the duration from Clock::now() until the time point t.  — end note ]

16.2.1 Mutable buffer sequence requirements [buffer.reqmts.mutablebuffersequence]

Table 12 — MutableBufferSequence requirements
expressionreturn typeassertion/note
pre/post-condition
net::buffer_sequence_begin(x)
net::buffer_sequence_end(x)
An iterator type whose reference type is convertible to mutable_buffer, and which satisfies all the requirements for bidirectional iterators (C++ 2014 [bidirectional.iterators]) except that:
  • there is no requirement that operator-> is provided, and

  • there is no requirement that reference be a reference type.

For a dereferenceable iterator, no increment, decrement, or dereference operation, or conversion of the reference type to mutable_buffer, shall exit via an exception.
X u(x); post:
equal(
  net::buffer_sequence_begin(x),
  net::buffer_sequence_end(x),
  net::buffer_sequence_begin(u),
  net::buffer_sequence_end(u),
  [](const mutable_buffer& b1,
     const mutable_buffer& b2)
   {
     return b1.data() == b2.data()
         && b1.size() == b2.size();
   })

16.2.2 Constant buffer sequence requirements [buffer.reqmts.constbuffersequence]

Table 13 — ConstBufferSequence requirements
expressionreturn typeassertion/note
pre/post-condition
net::buffer_sequence_begin(x)
net::buffer_sequence_end(x)
An iterator type whose reference type is convertible to const_buffer, and which satisfies all the requirements for bidirectional iterators (C++ 2014 [bidirectional.iterators]) except that:
  • there is no requirement that operator-> is provided, and

  • there is no requirement that reference be a reference type.

For a dereferenceable iterator, no increment, decrement, or dereference operation, or conversion of the reference type to const_buffer, shall exit via an exception.
X u(x); post:
equal(
  net::buffer_sequence_begin(x),
  net::buffer_sequence_end(x),
  net::buffer_sequence_begin(u),
  net::buffer_sequence_end(u),
  [](const const_buffer& b1,
     const const_buffer& b2)
   {
     return b1.data() == b2.data()
         && b1.size() == b2.size();
   })

16.2.4 Dynamic buffer requirements [buffer.reqmts.dynamicbuffer]

Table 14 — DynamicBuffer requirements
expressiontypeassertion/note pre/post-conditions
X::const_buffers_type type meeting ConstBufferSequence ([buffer.reqmts.constbuffersequence]) requirements. This type represents the memory associated with the readable bytes.
X::mutable_buffers_type type meeting MutableBufferSequence ([buffer.reqmts.constbuffersequence]) requirements. This type represents the memory associated with the writable bytes.
x1.size() size_t Returns the number of readable bytes.
x1.max_size() size_t Returns the maximum number of bytes, both readable and writable, that can be held by x1.
x1.capacity() size_t Returns the maximum number of bytes, both readable and writable, that can be held by x1 without requiring reallocation.
x1.data() X::const_buffers_type Returns a constant buffer sequence u that represents the readable bytes, and where buffer_size(u) == size().
x.prepare(n) X::mutable_buffers_type Returns a mutable buffer sequence u representing the writable bytes, and where buffer_size(u) == n. The dynamic buffer reallocates memory as required. All constant or mutable buffer sequences previously obtained using data() or prepare() are invalidated.
Throws: length_error if size() + n exceeds max_size().
x.commit(n) Appends n bytes from the start of the writable bytes to the end of the readable bytes. The remainder of the writable bytes are discarded. If n is greater than the number of writable bytes, all writable bytes are appended to the readable bytes. All constant or mutable buffer sequences previously obtained using data() or prepare() are invalidated.
x.consume(n) Removes n bytes from beginning of the readable bytes. If n is greater than the number of readable bytes, all readable bytes are removed. All constant or mutable buffer sequences previously obtained using data() or prepare() are invalidated.

16.6 Buffer type traits [buffer.traits]

Table 15 — Buffer type traits
TemplateConditionPreconditions
template<class T>
struct is_mutable_buffer_sequence
T meets the syntactic requirements for mutable buffer sequence ([buffer.reqmts.mutablebuffersequence]). T is a complete type.
template<class T>
struct is_const_buffer_sequence
T meets the syntactic requirements for constant buffer sequence ([buffer.reqmts.constbuffersequence]). T is a complete type.
template<class T>
struct is_dynamic_buffer
T meets the syntactic requirements for dynamic buffer ([buffer.reqmts.dynamicbuffer]). T is a complete type.

17.1.1 Buffer-oriented synchronous read stream requirements [buffer.stream.reqmts.syncreadstream]

Table 16 — SyncReadStream requirements
operationtypesemantics, pre/post-conditions
a.read_some(mb) a.read_some(mb,ec) size_t Meets the requirements for a read operation ([buffer.reqmts.read.write]).
If buffer_size(mb) > 0, reads one or more bytes of data from the stream a into the buffer sequence mb. If successful, sets ec such that !ec is true, and returns the number of bytes read. If an error occurred, sets ec such that !!ec is true, and returns 0. If all data has been read from the stream, and the stream performed an orderly shutdown, sets ec to stream_errc::eof and returns 0. If buffer_size(mb) == 0, the operation shall not block. Sets ec such that !ec is true, and returns 0.

17.1.2 Buffer-oriented asynchronous read stream requirements [buffer.stream.reqmts.asyncreadstream]

Table 17 — AsyncReadStream requirements
operationtypesemantics, pre/post-conditions
a.get_executor() A type satisfying the Executor requirements ([async.reqmts.executor]). Returns the associated I/O executor.
a.async_read_some(mb,t) The return type is determined according to the requirements for an asynchronous operation ([async.reqmts.async]). Meets the requirements for a read operation ([buffer.reqmts.read.write]) and an asynchronous operation ([async.reqmts.async]) with completion signature void(error_code ec, size_t n).
If buffer_size(mb) > 0, initiates an asynchronous operation to read one or more bytes of data from the stream a into the buffer sequence mb. If successful, ec is set such that !ec is true, and n is the number of bytes read. If an error occurred, ec is set such that !!ec is true, and n is 0. If all data has been read from the stream, and the stream performed an orderly shutdown, ec is stream_errc::eof and n is 0. If buffer_size(mb) == 0, the operation completes immediately. ec is set such that !ec is true, and n is 0.

17.1.3 Buffer-oriented synchronous write stream requirements [buffer.stream.reqmts.syncwritestream]

Table 18 — SyncWriteStream requirements
operationtypesemantics, pre/post-conditions
a.write_some(cb) a.write_some(cb,ec) size_t Meets the requirements for a write operation ([buffer.reqmts.read.write]).
If buffer_size(cb) > 0, writes one or more bytes of data to the stream a from the buffer sequence cb. If successful, sets ec such that !ec is true, and returns the number of bytes written. If an error occurred, sets ec such that !!ec is true, and returns 0. If buffer_size(cb) == 0, the operation shall not block. Sets ec such that !ec is true, and returns 0.

17.1.4 Buffer-oriented asynchronous write stream requirements [buffer.stream.reqmts.asyncwritestream]

Table 19 — AsyncWriteStream requirements
operationtypesemantics, pre/post-conditions
a.get_executor() A type satisfying the Executor requirements ([async.reqmts.executor]). Returns the associated I/O executor.
a.async_write_some(cb,t) The return type is determined according to the requirements for an asynchronous operation ([async.reqmts.async]). Meets the requirements for a write operation ([buffer.reqmts.read.write]) and an asynchronous operation ([async.reqmts.async]) with completion signature void(error_code ec, size_t n).
If buffer_size(cb) > 0, initiates an asynchronous operation to write one or more bytes of data to the stream a from the buffer sequence cb. If successful, ec is set such that !ec is true, and n is the number of bytes written. If an error occurred, ec is set such that !!ec is true, and n is 0. If buffer_size(cb) == 0, the operation completes immediately. ec is set such that !ec is true, and n is 0.

17.1.5 Completion condition requirements [buffer.stream.reqmts.completioncondition]

Table 20 — CompletionCondition requirements
expressionreturn typeassertion/note pre/post-condition
x(ec, n) size_t Let n be the total number of bytes transferred by the read or write algorithm so far.
Returns the maximum number of bytes to be transferred on the next read_some, async_read_some, write_some, or async_write_some operation performed by the algorithm. Returns 0 to indicate that the algorithm is complete.

18.2.4 Endpoint requirements [socket.reqmts.endpoint]

Table 21 — Endpoint requirements
expressiontypeassertion/note pre/post-conditions
X::protocol_type type meeting Protocol ([socket.reqmts.protocol]) requirements
a.protocol() protocol_type

18.2.4 Endpoint requirements [socket.reqmts.endpoint]

Table 22 — Endpoint requirements for extensible implementations
expressiontypeassertion/note pre/post-conditions
a.data() const void* Returns a pointer suitable for passing as the address argument to functions such as POSIX connect, or as the dest_addr argument to functions such as POSIX sendto. The implementation shall perform a static_cast on the pointer to convert it to const sockaddr*.
b.data() void* Returns a pointer suitable for passing as the address argument to functions such as POSIX accept, getpeername, getsockname and recvfrom. The implementation shall perform a static_cast on the pointer to convert it to sockaddr*.
a.size() size_t Returns a value suitable for passing as the address_len argument to functions such as POSIX connect, or as the dest_len argument to functions such as POSIX sendto, after appropriate integer conversion has been performed.
b.resize(s) pre: s >= 0
post: a.size() == s
Passed the value contained in the address_len argument to functions such as POSIX accept, getpeername, getsockname, and recvfrom, after successful completion of the function. Permitted to throw an exception if the protocol associated with the endpoint object a does not support the specified size.
a.capacity() size_t Returns a value suitable for passing as the address_len argument to functions such as POSIX accept, getpeername, getsockname, and recvfrom, after appropriate integer conversion has been performed.

18.2.5 Endpoint sequence requirements [socket.reqmts.endpointsequence]

Table 23 — EndpointSequence requirements
expressionreturn typeassertion/note pre/post-condition
x.begin()
x.end()
A type meeting the requirements for forward iterators (C++ 2014 [forward.iterators]) whose value type is convertible to a type satisfying the Endpoint ([socket.reqmts.endpoint]) requirements. [x.begin(), x.end()) is a valid range.

18.2.6 Protocol requirements [socket.reqmts.protocol]

Table 24 — Protocol requirements
expressionreturn typeassertion/note pre/post-conditions
X::endpoint type meeting endpoint ([socket.reqmts.endpoint]) requirements

18.2.6 Protocol requirements [socket.reqmts.protocol]

Table 25 — Protocol requirements for extensible implementations
expressionreturn typeassertion/note pre/post-conditions
a.family() int Returns a value suitable for passing as the domain argument to POSIX socket (or equivalent).
a.type() int Returns a value suitable for passing as the type argument to POSIX socket (or equivalent).
a.protocol() int Returns a value suitable for passing as the protocol argument to POSIX socket (or equivalent).

18.2.7 Acceptable protocol requirements [socket.reqmts.acceptableprotocol]

Table 26 — AcceptableProtocol requirements
expressionreturn typeassertion/note pre/post-conditions
X::socket A type that satisfies the requirements of Destructible (C++ 2014 [destructible]) and MoveConstructible (C++ 2014 [moveconstructible]), and that is publicly and unambiguously derived from basic_socket<X>.

18.2.8 Gettable socket option requirements [socket.reqmts.gettablesocketoption]

Table 27 — GettableSocketOption requirements for extensible implementations
expressiontypeassertion/note pre/post-conditions
a.level(p) int Returns a value suitable for passing as the level argument to POSIX getsockopt (or equivalent).
a.name(p) int Returns a value suitable for passing as the option_name argument to POSIX getsockopt (or equivalent).
b.data(p) void* Returns a pointer suitable for passing as the option_value argument to POSIX getsockopt (or equivalent).
a.size(p) size_t Returns a value suitable for passing as the option_len argument to POSIX getsockopt (or equivalent), after appropriate integer conversion has been performed.
b.resize(p,s) post: b.size(p) == s. Passed the value contained in the option_len argument to POSIX getsockopt (or equivalent) after successful completion of the function. Permitted to throw an exception if the socket option object b does not support the specified size.

18.2.9 Settable socket option requirements [socket.reqmts.settablesocketoption]

Table 28 — SettableSocketOption requirements for extensible implementations
expressiontypeassertion/note pre/post-conditions
a.level(p) int Returns a value suitable for passing as the level argument to POSIX setsockopt (or equivalent).
a.name(p) int Returns a value suitable for passing as the option_name argument to POSIX setsockopt (or equivalent).
a.data(p) const void* Returns a pointer suitable for passing as the option_value argument to POSIX setsockopt (or equivalent).
a.size(p) size_t Returns a value suitable for passing as the option_len argument to POSIX setsockopt (or equivalent), after appropriate integer conversion has been performed.

18.2.10 Boolean socket options [socket.reqmts.opt.bool]

Table 29 — BooleanSocketOption requirements
expressiontypeassertion/note pre/post-conditions
X u; post: !u.value().
X u(v); post: u.value() == v.
a.value() bool Returns the current boolean value of the socket option object.
static_cast<bool>(a) bool Returns a.value().
!a bool Returns !a.value().

18.2.11 Integer socket options [socket.reqmts.opt.int]

Table 30 — IntegerSocketOption requirements
expressiontypeassertion/note pre/post-conditions
X u; post: u.value() == 0.
X u(v); post: u.value() == v.
a.value() int Returns the current integer value of the socket option object.

18.2.12 I/O control command requirements [socket.reqmts.iocontrolcommand]

Table 31 — IoControlCommand requirements for extensible implementations
expressiontypeassertion/note pre/post-conditions
a.name() int Returns a value suitable for passing as the request argument to POSIX ioctl (or equivalent).
b.data() void*

18.2.13 Connect condition requirements [socket.reqmts.connectcondition]

Table 32 — ConnectCondition requirements
expressionreturn typeassertion/note pre/post-condition
x(ec, ep) bool Returns true to indicate that the connect or async_connect algorithm should attempt a connection to the endpoint ep. Otherwise, returns false to indicate that the algorithm should not attempt connection to the endpoint ep, and should instead skip to the next endpoint in the sequence.

18.4 Class socket_base [socket.base]

Table 33socket_base constants
Constant NamePOSIX macroDefinition or notes
shutdown_receive SHUT_RD Disables further receive operations.
shutdown_send SHUT_WR Disables further send operations.
shutdown_both SHUT_RDWR Disables further send and receive operations.
wait_read Wait until the socket is ready-to-read. For a given socket, when a wait or async_wait operation using wait_read completes successfully, a subsequent call to the socket's receive or receive_from functions may complete without blocking. Similarly, for a given acceptor, when a wait or async_wait operation using wait_read completes successfully, a subsequent call to the acceptor's accept function may complete without blocking.
wait_write Wait until the socket is ready-to-write. For a given socket, when a wait or async_wait operation using wait_write completes successfully, a subsequent call to the socket's send or send_to functions may complete without blocking.
wait_error Wait until the socket has a pending error condition. For a given socket, when a wait or async_wait operation using wait_error completes successfully, a subsequent call to one of the socket's synchronous operations may complete without blocking. The nature of the pending error condition determines which.
message_peek MSG_PEEK Leave received data in queue.
message_out_of_band MSG_OOB Out-of-band data.
message_do_not_route MSG_DONTROUTE Send without using routing tables.
max_listen_connections SOMAXCONN The implementation-defined limit on the length of the queue of pending incoming connections.

18.5 Socket options [socket.opt]

Table 34 — Socket options
CLNTRequirements, definition or notes
socket_base:: broadcast SOL_SOCKET SO_BROADCAST int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether a socket permits sending of broadcast messages, if supported by the protocol.
socket_base:: debug SOL_SOCKET SO_DEBUG int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether debugging information is recorded by the underlying protocol.
socket_base:: do_not_route SOL_SOCKET SO_DONTROUTE int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether outgoing messages bypass standard routing facilities.
socket_base:: keep_alive SOL_SOCKET SO_KEEPALIVE int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether a socket permits sending of keep_alive messages, if supported by the protocol.
socket_base:: linger ([socket.opt.linger]) SOL_SOCKET SO_LINGER linger Controls the behavior when a socket is closed and unsent data is present.
socket_base:: out_of_band_inline SOL_SOCKET SO_OOBINLINE int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether out-of-band data (also known as urgent data) is received inline.
socket_base:: receive_buffer_size SOL_SOCKET SO_RCVBUF int Satisfies the IntegerSocketOption ([socket.reqmts.opt.int]) type requirements. Specifies the size of the receive buffer associated with a socket.
socket_base:: receive_low_watermark SOL_SOCKET SO_RCVLOWAT int Satisfies the IntegerSocketOption ([socket.reqmts.opt.int]) type requirements. Specifies the minimum number of bytes to process for socket input operations.
socket_base:: reuse_address SOL_SOCKET SO_REUSEADDR int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether the validation of endpoints used for binding a socket should allow the reuse of local endpoints, if supported by the protocol.
socket_base:: send_buffer_size SOL_SOCKET SO_SNDBUF int Satisfies the IntegerSocketOption ([socket.reqmts.opt.int]) type requirements. Specifies the size of the send buffer associated with a socket.
socket_base:: send_low_watermark SOL_SOCKET SO_SNDLOWAT int Satisfies the IntegerSocketOption ([socket.reqmts.opt.int]) type requirements. Specifies the minimum number of bytes to process for socket output operations.

21.2.1 Internet protocol requirements [internet.reqmts.protocol]

Table 35 — InternetProtocol requirements
expressionreturn typeassertion/note pre/post-conditions
X::resolver ip::basic_resolver<X> The type of a resolver for the protocol.
X::v4() X Returns an object representing the IP version 4 protocol.
X::v6() X Returns an object representing the IP version 6 protocol.
a == b convertible to bool Returns true if a and b represent the same IP protocol version, otherwise false.
a != b convertible to bool Returns !(a == b).

21.2.2 Multicast group socket options [internet.reqmts.opt.mcast]

Table 36 — MulticastGroupSocketOption requirements
expressiontypeassertion/note pre/post-conditions
X u(a); Constructs a multicast group socket option to join the group with the specified version-independent address.
X u(b, c); Constructs a multicast group socket option to join the specified IPv4 address on a specified network interface.
X u(d, e); Constructs a multicast group socket option to join the specified IPv6 address on a specified network interface.

21.16 Class ip::resolver_base [internet.resolver.base]

Table 37 — Resolver flags
Constant namePOSIX macroDefinition or notes
passive AI_PASSIVE Returned endpoints are intended for use as locally bound socket endpoints.
canonical_name AI_CANONNAME Determine the canonical name of the host specified in the query.
numeric_host AI_NUMERICHOST Host name should be treated as a numeric string defining an IPv4 or IPv6 address and no host name resolution should be attempted.
numeric_service AI_NUMERICSERV Service name should be treated as a numeric string defining a port number and no service name resolution should be attempted.
v4_mapped AI_V4MAPPED If the protocol is specified as an IPv6 protocol, return IPv4-mapped IPv6 addresses on finding no IPv6 addresses.
all_matching AI_ALL If used with v4_mapped, return all matching IPv6 and IPv4 addresses.
address_configured AI_ADDRCONFIG Only return IPv4 addresses if a non-loopback IPv4 address is configured for the system. Only return IPv6 addresses if a non-loopback IPv6 address is configured for the system.

21.19 Class ip::tcp [internet.tcp]

Table 38 — Behavior of extensible ip::tcp implementations
valuefamily()type()protocol()
tcp::v4() AF_INET SOCK_STREAM IPPROTO_TCP
tcp::v6() AF_INET6 SOCK_STREAM IPPROTO_TCP

21.20 Class ip::udp [internet.udp]

Table 39 — Behavior of extensible ip::udp implementations
valuefamily()type()protocol()
udp::v4() AF_INET SOCK_DGRAM IPPROTO_UDP
udp::v6() AF_INET6 SOCK_DGRAM IPPROTO_UDP

21.21 Internet socket options [internet.socket.opt]

Table 40 — Internet socket options
CLNTRequirements,
definition or notes
ip::tcp::
no_delay
IPPROTO_TCP TCP_NODELAY int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) 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 ]
ip::v6_only IPPROTO_IPV6 IPV6_V6ONLY int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) 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:: hops IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_UNICAST_HOPS if F == AF_INET6, otherwise IP_TTL int Satisfies the IntegerSocketOption ([socket.reqmts.opt.int]) type 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].
ip::multicast:: join_group IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_JOIN_GROUP if F == AF_INET6, otherwise IP_ADD_MEMBERSHIP ipv6_mreq if F == AF_INET6, otherwise ip_mreq Satisfies the MulticastGroupSocketOption ([internet.reqmts.opt.mcast]) type requirements. Requests that the socket join the specified multicast group.
ip::multicast:: leave_group IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_LEAVE_GROUP if F == AF_INET6, otherwise IP_DROP_MEMBERSHIP ipv6_mreq if F == AF_INET6, otherwise ip_mreq Satisfies the MulticastGroupSocketOption ([internet.reqmts.opt.mcast]) type requirements. Requests that the socket leave the specified multicast group.
ip::multicast:: outbound_interface
([internet.multicast.outbound])
IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_MULTICAST_IF if F == AF_INET6, otherwise IP_MULTICAST_IF unsigned int if F == AF_INET6, otherwise in_addr Specifies the network interface to use for outgoing multicast datagrams.
ip::multicast:: hops IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_MULTICAST_HOPS if F == AF_INET6, otherwise IP_MULTICAST_TTL int Satisfies the IntegerSocketOption ([socket.reqmts.opt.int]) type 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::multicast::hops class throw out_of_range if the int argument is not in the range [0, 255].
ip::multicast:: enable_loopback IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_MULTICAST_LOOP if F == AF_INET6, otherwise IP_MULTICAST_LOOP int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether multicast datagrams are delivered back to the local application.