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 |
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 |
Rebinds the acceptor type to another executor. |
|
The endpoint type. |
|
The type of the executor associated with the object. |
|
Bitmask type for flags that can be passed to send and receive operations. |
|
The protocol type. |
|
Member Functions
Name |
Description |
|
Constructors |
|
Destroys the acceptor. |
Assignment operators |
|
|
|
Start an asynchronous accept. |
|
Asynchronously wait for the acceptor to become ready to read, ready to write, or to have pending error conditions. |
|
Bind the acceptor to the given local endpoint. |
|
Cancel all asynchronous operations associated with the acceptor. |
|
Close the acceptor. |
|
Get the executor associated with the object. |
|
Get an option from the acceptor. |
|
Perform an IO control command on the acceptor. |
|
Determine whether the acceptor is open. |
|
Place the acceptor into the state where it will listen for new connections. |
|
Get the local endpoint of the acceptor. |
|
Get the native acceptor representation. |
|
|
|
|
|
Open the acceptor using the specified protocol. |
|
Set an option on the acceptor. |
|
Wait for the acceptor to become ready to read, ready to write, or to have pending error conditions. |
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