boost::asio::basic_socket_acceptor

Provides the ability to accept new connections.

Synopsis

Declared in <boost/asio/basic_socket_acceptor.hpp>

template<
    typename Protocol,
    typename Executor = any_io_executor>
class basic_socket_acceptor
    : public socket_base

Base Classes

Name

Description

socket_base

The socket_base class is used as a base for the basic_stream_socket and basic_datagram_socket class templates so that we have a common place to define the shutdown_type and enum.

Types

Name

Description

rebind_executor

Rebinds the acceptor type to another executor.

broadcast

bytes_readable

debug

do_not_route

enable_connection_aborted

endpoint_type

The endpoint type.

executor_type

The type of the executor associated with the object.

keep_alive

linger

message_flags

Bitmask type for flags that can be passed to send and receive operations.

native_handle_type

out_of_band_inline

protocol_type

The protocol type.

receive_buffer_size

receive_low_watermark

reuse_address

send_buffer_size

send_low_watermark

Enums

Name

Description

shutdown_type

Different ways a socket may be shutdown.

wait_type

Wait types.

Member Functions

Name

Description

basic_socket_acceptor [constructor]

Constructors

~basic_socket_acceptor [destructor]

Destroys the acceptor.

operator=

Assignment operators

accept

accept overloads

assign

async_accept

Start an asynchronous accept.

async_wait

Asynchronously wait for the acceptor to become ready to read, ready to write, or to have pending error conditions.

bind

Bind the acceptor to the given local endpoint.

cancel

Cancel all asynchronous operations associated with the acceptor.

close

Close the acceptor.

get_executor

Get the executor associated with the object.

get_option

Get an option from the acceptor.

io_control

Perform an IO control command on the acceptor.

is_open

Determine whether the acceptor is open.

listen

Place the acceptor into the state where it will listen for new connections.

local_endpoint

Get the local endpoint of the acceptor.

native_handle

Get the native acceptor representation.

native_non_blocking

native_non_blocking overloads

non_blocking

non_blocking overloads

open

Open the acceptor using the specified protocol.

release

set_option

Set an option on the acceptor.

wait

Wait for the acceptor to become ready to read, ready to write, or to have pending error conditions.

Friends

Name

Description

boost::asio::basic_socket_acceptor

Provides the ability to accept new connections.

Description

The basic_socket_acceptor class template is used for accepting new socket connections.

Thread Safety

Distinct objects: Safe. Shared objects: Unsafe.

Synchronous accept operations are thread safe, if the underlying operating system calls are also thread safe. This means that it is permitted to perform concurrent calls to synchronous accept operations on a single socket object. Other synchronous operations, such as open or close, are not thread safe.

Example

Opening a socket acceptor with the SO_REUSEADDR option enabled:

boost::asio::ip::tcp::acceptor acceptor(my_context);
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), port);
acceptor.open(endpoint.protocol());
acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
acceptor.bind(endpoint);
acceptor.listen();

Created with MrDocs