| Home | Libraries | People | FAQ | More

### basic_socket_acceptor

Provides the ability to accept new connections.

    template<
        typename Protocol,
        typename SocketAcceptorService = socket_acceptor_service<Protocol>>
    class basic_socket_acceptor :
      public basic_io_object< SocketAcceptorService >,
      public socket_base

##### Types

Name | Description
--- | ---
broadcast | Socket option to permit sending of broadcast messages.
bytes_readable | IO control command to get the amount of data that can be read without blocking.
debug | Socket option to enable socket-level debugging.
do_not_route | Socket option to prevent routing, use local interfaces only.
enable_connection_aborted | Socket option to report aborted connections on accept.
endpoint_type | The endpoint type.
implementation_type | The underlying implementation type of I/O object.
keep_alive | Socket option to send keep-alives.
linger | Socket option to specify whether the socket lingers on close if unsent data is present.
message_flags | Bitmask type for flags that can be passed to send and receive operations.
native_type | The native representation of an acceptor.
non_blocking_io | IO control command to set the blocking mode of the socket.
protocol_type | The protocol type.
receive_buffer_size | Socket option for the receive buffer size of a socket.
receive_low_watermark | Socket option for the receive low watermark.
reuse_address | Socket option to allow the socket to be bound to an address that is already in use.
send_buffer_size | Socket option for the send buffer size of a socket.
send_low_watermark | Socket option for the send low watermark.
service_type | The type of the service that will be used to provide I/O operations.
shutdown_type | Different ways a socket may be shutdown.

##### Member Functions

Name | Description
--- | ---
accept | Accept a new connection. Accept a new connection and obtain the endpoint of the peer.
assign | Assigns an existing native acceptor to the acceptor.
async_accept | Start an asynchronous accept.
basic_socket_acceptor | Construct an acceptor without opening it. Construct an open acceptor. Construct an acceptor opened on the given endpoint. Construct a basic_socket_acceptor on an existing native acceptor.
bind | Bind the acceptor to the given local endpoint.
cancel | Cancel all asynchronous operations associated with the acceptor.
close | Close the acceptor.
get_io_service | Get the io_service associated with the object.
get_option | Get an option from the acceptor.
io_service | (Deprecated: use get_io_service().) Get the io_service associated with the object.
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 | Get the native acceptor representation.
open | Open the acceptor using the specified protocol.
set_option | Set an option on the acceptor.

##### Data Members

Name | Description
--- | ---
max_connections | The maximum length of the queue of pending incoming connections.
message_do_not_route | Specify that the data should not be subject to routing.
message_out_of_band | Process out-of-band data.
message_peek | Peek at incoming data without removing it from the input queue.

##### Protected Data Members

Name | Description
--- | ---
implementation | The underlying implementation of the I/O object.
service | The service associated with the I/O object.

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

##### Thread Safety

Distinct objects: Safe.

Shared objects: Unsafe.

##### Example

Opening a socket acceptor with the SO_REUSEADDR option enabled:

    boost::asio::ip::tcp::acceptor acceptor(io_service);
    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();

##### Requirements

Header: `boost/asio/basic_socket_acceptor.hpp`

Convenience header: `boost/asio.hpp`