18 Sockets [socket]

18.9 Class template basic_socket_acceptor [socket.acceptor]

18.9.1 basic_socket_acceptor constructors [socket.acceptor.cons]

explicit basic_socket_acceptor(io_context& ctx);

Postconditions:

  • get_executor() == ctx.get_executor().

  • is_open() == false.

basic_socket_acceptor(io_context& ctx, const protocol_type& protocol);

Effects: Opens this acceptor as if by calling open(protocol).

Postconditions:

  • get_executor() == ctx.get_executor().

  • is_open() == true.

  • non_blocking() == false.

  • enable_connection_aborted() == false.

  • protocol_ == protocol.

basic_socket_acceptor(io_context& ctx, const endpoint_type& endpoint, bool reuse_addr = true);

Effects: Opens and binds this acceptor as if by calling:

open(endpoint.protocol());
if (reuse_addr)
  set_option(reuse_address(true));
bind(endpoint);
listen();

Postconditions:

  • get_executor() == ctx.get_executor().

  • is_open() == true.

  • non_blocking() == false.

  • enable_connection_aborted() == false.

  • protocol_ == endpoint.protocol().

basic_socket_acceptor(io_context& ctx, const protocol_type& protocol, const native_handle_type& native_acceptor);

Requires: native_acceptor is a native handle to an open acceptor.

Effects: Assigns the existing native acceptor into this acceptor as if by calling assign(protocol, native_acceptor).

Postconditions:

  • get_executor() == ctx.get_executor().

  • is_open() == true.

  • non_blocking() == false.

  • enable_connection_aborted() == false.

  • protocol_ == protocol.

basic_socket_acceptor(basic_socket_acceptor&& rhs);

Effects: Move constructs an object of class basic_socket_acceptor<AcceptableProtocol> that refers to the state originally represented by rhs.

Postconditions:

  • get_executor() == rhs.get_executor().

  • is_open() returns the same value as rhs.is_open() prior to the constructor invocation.

  • non_blocking() returns the same value as rhs.non_blocking() prior to the constructor invocation.

  • enable_connection_aborted() returns the same value as rhs.enable_connection_aborted() prior to the constructor invocation.

  • native_handle() returns the same value as rhs.native_handle() prior to the constructor invocation.

  • protocol_ is equal to the prior value of rhs.protocol_.

  • rhs.is_open() == false.

template<class OtherProtocol> basic_socket_acceptor(basic_socket_acceptor<OtherProtocol>&& rhs);

Requires: OtherProtocol is implicitly convertible to Protocol.

Effects: Move constructs an object of class basic_socket_acceptor<AcceptableProtocol> that refers to the state originally represented by rhs.

Postconditions:

  • get_executor() == rhs.get_executor().

  • is_open() returns the same value as rhs.is_open() prior to the constructor invocation.

  • non_blocking() returns the same value as rhs.non_blocking() prior to the constructor invocation.

  • enable_connection_aborted() returns the same value as rhs.enable_connection_aborted() prior to the constructor invocation.

  • native_handle() returns the prior value of rhs.native_handle().

  • protocol_ is the result of converting the prior value of rhs.protocol_.

  • rhs.is_open() == false.

Remarks: This constructor shall not participate in overload resolution unless OtherProtocol is implicitly convertible to Protocol.