Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService > Class Template Reference

Provides the ability to accept new connections. More...

#include <basic_socket_acceptor.hpp>

Inheritance diagram for boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >:
Collaboration diagram for boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >:

Public Types

typedef
SocketAcceptorService::native_handle_type 
native_type
 (Deprecated: Use native_handle_type.) The native representation of an acceptor. More...
 
typedef
SocketAcceptorService::native_handle_type 
native_handle_type
 The native representation of an acceptor. More...
 
typedef Protocol protocol_type
 The protocol type. More...
 
typedef Protocol::endpoint endpoint_type
 The endpoint type. More...
 
typedef SocketAcceptorService service_type
 The type of the service that will be used to provide I/O operations. More...
 
typedef
service_type::implementation_type 
implementation_type
 The underlying implementation type of I/O object. More...
 
enum  shutdown_type {
  shutdown_receive = BOOST_ASIO_OS_DEF(SHUT_RD),
  shutdown_send = BOOST_ASIO_OS_DEF(SHUT_WR),
  shutdown_both = BOOST_ASIO_OS_DEF(SHUT_RDWR)
}
 Different ways a socket may be shutdown. More...
 
typedef int message_flags
 Bitmask type for flags that can be passed to send and receive operations. More...
 
typedef
boost::asio::detail::socket_option::boolean
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_BROADCAST)> 
broadcast
 Socket option to permit sending of broadcast messages. More...
 
typedef
boost::asio::detail::socket_option::boolean
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_DEBUG)> 
debug
 Socket option to enable socket-level debugging. More...
 
typedef
boost::asio::detail::socket_option::boolean
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_DONTROUTE)> 
do_not_route
 Socket option to prevent routing, use local interfaces only. More...
 
typedef
boost::asio::detail::socket_option::boolean
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_KEEPALIVE)> 
keep_alive
 Socket option to send keep-alives. More...
 
typedef
boost::asio::detail::socket_option::integer
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_SNDBUF)> 
send_buffer_size
 Socket option for the send buffer size of a socket. More...
 
typedef
boost::asio::detail::socket_option::integer
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_SNDLOWAT)> 
send_low_watermark
 Socket option for the send low watermark. More...
 
typedef
boost::asio::detail::socket_option::integer
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_RCVBUF)> 
receive_buffer_size
 Socket option for the receive buffer size of a socket. More...
 
typedef
boost::asio::detail::socket_option::integer
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_RCVLOWAT)> 
receive_low_watermark
 Socket option for the receive low watermark. More...
 
typedef
boost::asio::detail::socket_option::boolean
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_REUSEADDR)> 
reuse_address
 Socket option to allow the socket to be bound to an address that is already in use. More...
 
typedef
boost::asio::detail::socket_option::linger
< BOOST_ASIO_OS_DEF(SOL_SOCKET),
BOOST_ASIO_OS_DEF(SO_LINGER)> 
linger
 Socket option to specify whether the socket lingers on close if unsent data is present. More...
 
typedef
boost::asio::detail::socket_option::boolean
< boost::asio::detail::custom_socket_option_level,
boost::asio::detail::enable_connection_aborted_option > 
enable_connection_aborted
 Socket option to report aborted connections on accept. More...
 
typedef
boost::asio::detail::io_control::non_blocking_io 
non_blocking_io
 (Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. More...
 
typedef
boost::asio::detail::io_control::bytes_readable 
bytes_readable
 IO control command to get the amount of data that can be read without blocking. More...
 

Public Member Functions

 basic_socket_acceptor (boost::asio::io_service &io_service)
 Construct an acceptor without opening it. More...
 
 basic_socket_acceptor (boost::asio::io_service &io_service, const protocol_type &protocol)
 Construct an open acceptor. More...
 
 basic_socket_acceptor (boost::asio::io_service &io_service, const endpoint_type &endpoint, bool reuse_addr=true)
 Construct an acceptor opened on the given endpoint. More...
 
 basic_socket_acceptor (boost::asio::io_service &io_service, const protocol_type &protocol, const native_handle_type &native_acceptor)
 Construct a basic_socket_acceptor on an existing native acceptor. More...
 
void open (const protocol_type &protocol=protocol_type())
 Open the acceptor using the specified protocol. More...
 
boost::system::error_code open (const protocol_type &protocol, boost::system::error_code &ec)
 Open the acceptor using the specified protocol. More...
 
void assign (const protocol_type &protocol, const native_handle_type &native_acceptor)
 Assigns an existing native acceptor to the acceptor. More...
 
boost::system::error_code assign (const protocol_type &protocol, const native_handle_type &native_acceptor, boost::system::error_code &ec)
 Assigns an existing native acceptor to the acceptor. More...
 
bool is_open () const
 Determine whether the acceptor is open. More...
 
void bind (const endpoint_type &endpoint)
 Bind the acceptor to the given local endpoint. More...
 
boost::system::error_code bind (const endpoint_type &endpoint, boost::system::error_code &ec)
 Bind the acceptor to the given local endpoint. More...
 
void listen (int backlog=socket_base::max_connections)
 Place the acceptor into the state where it will listen for new connections. More...
 
boost::system::error_code listen (int backlog, boost::system::error_code &ec)
 Place the acceptor into the state where it will listen for new connections. More...
 
void close ()
 Close the acceptor. More...
 
boost::system::error_code close (boost::system::error_code &ec)
 Close the acceptor. More...
 
native_type native ()
 (Deprecated: Use native_handle().) Get the native acceptor representation. More...
 
native_handle_type native_handle ()
 Get the native acceptor representation. More...
 
void cancel ()
 Cancel all asynchronous operations associated with the acceptor. More...
 
boost::system::error_code cancel (boost::system::error_code &ec)
 Cancel all asynchronous operations associated with the acceptor. More...
 
template<typename SettableSocketOption >
void set_option (const SettableSocketOption &option)
 Set an option on the acceptor. More...
 
template<typename SettableSocketOption >
boost::system::error_code set_option (const SettableSocketOption &option, boost::system::error_code &ec)
 Set an option on the acceptor. More...
 
template<typename GettableSocketOption >
void get_option (GettableSocketOption &option)
 Get an option from the acceptor. More...
 
template<typename GettableSocketOption >
boost::system::error_code get_option (GettableSocketOption &option, boost::system::error_code &ec)
 Get an option from the acceptor. More...
 
template<typename IoControlCommand >
void io_control (IoControlCommand &command)
 Perform an IO control command on the acceptor. More...
 
template<typename IoControlCommand >
boost::system::error_code io_control (IoControlCommand &command, boost::system::error_code &ec)
 Perform an IO control command on the acceptor. More...
 
bool non_blocking () const
 Gets the non-blocking mode of the acceptor. More...
 
void non_blocking (bool mode)
 Sets the non-blocking mode of the acceptor. More...
 
boost::system::error_code non_blocking (bool mode, boost::system::error_code &ec)
 Sets the non-blocking mode of the acceptor. More...
 
bool native_non_blocking () const
 Gets the non-blocking mode of the native acceptor implementation. More...
 
void native_non_blocking (bool mode)
 Sets the non-blocking mode of the native acceptor implementation. More...
 
boost::system::error_code native_non_blocking (bool mode, boost::system::error_code &ec)
 Sets the non-blocking mode of the native acceptor implementation. More...
 
endpoint_type local_endpoint () const
 Get the local endpoint of the acceptor. More...
 
endpoint_type local_endpoint (boost::system::error_code &ec) const
 Get the local endpoint of the acceptor. More...
 
template<typename Protocol1 , typename SocketService >
void accept (basic_socket< Protocol1, SocketService > &peer, typename enable_if< is_convertible< Protocol, Protocol1 >::value >::type *=0)
 Accept a new connection. More...
 
template<typename Protocol1 , typename SocketService >
boost::system::error_code accept (basic_socket< Protocol1, SocketService > &peer, boost::system::error_code &ec, typename enable_if< is_convertible< Protocol, Protocol1 >::value >::type *=0)
 Accept a new connection. More...
 
template<typename Protocol1 , typename SocketService , typename AcceptHandler >
 BOOST_ASIO_INITFN_RESULT_TYPE (AcceptHandler, void(boost::system::error_code)) async_accept(basic_socket< Protocol1
 Start an asynchronous accept. More...
 
SocketService BOOST_ASIO_MOVE_ARG (AcceptHandler) handler
 
SocketService enable_if
< is_convertible< Protocol,
Protocol1 >::value >::type
AcceptHandler 
BOOST_ASIO_INITFN_RESULT_TYPE (AcceptHandler, void(boost::system::error_code)) async_accept(basic_socket< protocol_type
 
SocketService enable_if
< is_convertible< Protocol,
Protocol1 >::value >::type
AcceptHandler SocketService
endpoint_type 
BOOST_ASIO_MOVE_ARG (AcceptHandler) handler)
 
boost::asio::io_serviceget_io_service ()
 Get the io_service associated with the object. More...
 
 BOOST_ASIO_STATIC_CONSTANT (int, message_peek=BOOST_ASIO_OS_DEF(MSG_PEEK))
 
 BOOST_ASIO_STATIC_CONSTANT (int, message_out_of_band=BOOST_ASIO_OS_DEF(MSG_OOB))
 
 BOOST_ASIO_STATIC_CONSTANT (int, message_do_not_route=BOOST_ASIO_OS_DEF(MSG_DONTROUTE))
 
 BOOST_ASIO_STATIC_CONSTANT (int, message_end_of_record=BOOST_ASIO_OS_DEF(MSG_EOR))
 
 BOOST_ASIO_STATIC_CONSTANT (int, max_connections=BOOST_ASIO_OS_DEF(SOMAXCONN))
 The maximum length of the queue of pending incoming connections. More...
 

Public Attributes

SocketService & peer
 
SocketService enable_if
< is_convertible< Protocol,
Protocol1 >::value >::type
AcceptHandler SocketService & 
peer
 
SocketService enable_if
< is_convertible< Protocol,
Protocol1 >::value >::type
AcceptHandler SocketService
endpoint_type
peer_endpoint
 

Protected Member Functions

service_typeget_service ()
 Get the service associated with the I/O object. More...
 
const service_typeget_service () const
 Get the service associated with the I/O object. More...
 
implementation_typeget_implementation ()
 Get the underlying implementation of the I/O object. More...
 
const implementation_typeget_implementation () const
 Get the underlying implementation of the I/O object. More...
 

Protected Attributes

service_typeservice
 (Deprecated: Use get_service().) The service associated with the I/O object. More...
 
implementation_type implementation
 (Deprecated: Use get_implementation().) The underlying implementation of the I/O object. More...
 

Detailed Description

template<typename Protocol, typename SocketAcceptorService = socket_acceptor_service<Protocol>>
class boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >

Provides the ability to accept new connections.

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);
acceptor.open(endpoint.protocol());
acceptor.bind(endpoint);
acceptor.listen();

Member Typedef Documentation

typedef boost::asio::detail::socket_option::boolean< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_BROADCAST)> boost::asio::socket_base::broadcast
inherited

Socket option to permit sending of broadcast messages.

Implements the SOL_SOCKET/SO_BROADCAST socket option.

Examples
Setting the option:
boost::asio::ip::udp::socket socket(io_service);
...
boost::asio::socket_base::broadcast option(true);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::udp::socket socket(io_service);
...
boost::asio::socket_base::broadcast option;
socket.get_option(option);
bool is_set = option.value();
Concepts:
Socket_Option, Boolean_Socket_Option.
typedef boost::asio::detail::io_control::bytes_readable boost::asio::socket_base::bytes_readable
inherited

IO control command to get the amount of data that can be read without blocking.

Implements the FIONREAD IO control command.

Example
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::bytes_readable command(true);
socket.io_control(command);
std::size_t bytes_readable = command.get();
Concepts:
IO_Control_Command, Size_IO_Control_Command.
typedef boost::asio::detail::socket_option::boolean< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_DEBUG)> boost::asio::socket_base::debug
inherited

Socket option to enable socket-level debugging.

Implements the SOL_SOCKET/SO_DEBUG socket option.

Examples
Setting the option:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::debug option(true);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::debug option;
socket.get_option(option);
bool is_set = option.value();
Concepts:
Socket_Option, Boolean_Socket_Option.
typedef boost::asio::detail::socket_option::boolean< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_DONTROUTE)> boost::asio::socket_base::do_not_route
inherited

Socket option to prevent routing, use local interfaces only.

Implements the SOL_SOCKET/SO_DONTROUTE socket option.

Examples
Setting the option:
boost::asio::ip::udp::socket socket(io_service);
...
boost::asio::socket_base::do_not_route option(true);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::udp::socket socket(io_service);
...
boost::asio::socket_base::do_not_route option;
socket.get_option(option);
bool is_set = option.value();
Concepts:
Socket_Option, Boolean_Socket_Option.
typedef boost::asio::detail::socket_option::boolean< boost::asio::detail::custom_socket_option_level, boost::asio::detail::enable_connection_aborted_option> boost::asio::socket_base::enable_connection_aborted
inherited

Socket option to report aborted connections on accept.

Implements a custom socket option that determines whether or not an accept operation is permitted to fail with boost::asio::error::connection_aborted. By default the option is false.

Examples
Setting the option:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::socket_base::enable_connection_aborted option(true);
acceptor.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::socket_base::enable_connection_aborted option;
acceptor.get_option(option);
bool is_set = option.value();
Concepts:
Socket_Option, Boolean_Socket_Option.
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
typedef Protocol::endpoint boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::endpoint_type

The endpoint type.

typedef service_type::implementation_type boost::asio::basic_io_object< SocketAcceptorService >::implementation_type
inherited

The underlying implementation type of I/O object.

typedef boost::asio::detail::socket_option::boolean< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_KEEPALIVE)> boost::asio::socket_base::keep_alive
inherited

Socket option to send keep-alives.

Implements the SOL_SOCKET/SO_KEEPALIVE socket option.

Examples
Setting the option:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::keep_alive option(true);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::keep_alive option;
socket.get_option(option);
bool is_set = option.value();
Concepts:
Socket_Option, Boolean_Socket_Option.
typedef boost::asio::detail::socket_option::linger< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_LINGER)> boost::asio::socket_base::linger
inherited

Socket option to specify whether the socket lingers on close if unsent data is present.

Implements the SOL_SOCKET/SO_LINGER socket option.

Examples
Setting the option:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::linger option(true, 30);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::linger option;
socket.get_option(option);
bool is_set = option.enabled();
unsigned short timeout = option.timeout();
Concepts:
Socket_Option, Linger_Socket_Option.

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

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
typedef SocketAcceptorService::native_handle_type boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_handle_type

The native representation of an acceptor.

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
typedef SocketAcceptorService::native_handle_type boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_type

(Deprecated: Use native_handle_type.) The native representation of an acceptor.

typedef boost::asio::detail::io_control::non_blocking_io boost::asio::socket_base::non_blocking_io
inherited

(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket.

Implements the FIONBIO IO control command.

Example
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::non_blocking_io command(true);
socket.io_control(command);
Concepts:
IO_Control_Command, Boolean_IO_Control_Command.
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
typedef Protocol boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::protocol_type

The protocol type.

typedef boost::asio::detail::socket_option::integer< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_RCVBUF)> boost::asio::socket_base::receive_buffer_size
inherited

Socket option for the receive buffer size of a socket.

Implements the SOL_SOCKET/SO_RCVBUF socket option.

Examples
Setting the option:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::receive_buffer_size option(8192);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::receive_buffer_size option;
socket.get_option(option);
int size = option.value();
Concepts:
Socket_Option, Integer_Socket_Option.
typedef boost::asio::detail::socket_option::integer< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_RCVLOWAT)> boost::asio::socket_base::receive_low_watermark
inherited

Socket option for the receive low watermark.

Implements the SOL_SOCKET/SO_RCVLOWAT socket option.

Examples
Setting the option:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::receive_low_watermark option(1024);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::receive_low_watermark option;
socket.get_option(option);
int size = option.value();
Concepts:
Socket_Option, Integer_Socket_Option.
typedef boost::asio::detail::socket_option::boolean< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_REUSEADDR)> boost::asio::socket_base::reuse_address
inherited

Socket option to allow the socket to be bound to an address that is already in use.

Implements the SOL_SOCKET/SO_REUSEADDR socket option.

Examples
Setting the option:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::socket_base::reuse_address option(true);
acceptor.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::socket_base::reuse_address option;
acceptor.get_option(option);
bool is_set = option.value();
Concepts:
Socket_Option, Boolean_Socket_Option.
typedef boost::asio::detail::socket_option::integer< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_SNDBUF)> boost::asio::socket_base::send_buffer_size
inherited

Socket option for the send buffer size of a socket.

Implements the SOL_SOCKET/SO_SNDBUF socket option.

Examples
Setting the option:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::send_buffer_size option(8192);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::send_buffer_size option;
socket.get_option(option);
int size = option.value();
Concepts:
Socket_Option, Integer_Socket_Option.
typedef boost::asio::detail::socket_option::integer< BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_SNDLOWAT)> boost::asio::socket_base::send_low_watermark
inherited

Socket option for the send low watermark.

Implements the SOL_SOCKET/SO_SNDLOWAT socket option.

Examples
Setting the option:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::send_low_watermark option(1024);
socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service);
...
boost::asio::socket_base::send_low_watermark option;
socket.get_option(option);
int size = option.value();
Concepts:
Socket_Option, Integer_Socket_Option.
typedef SocketAcceptorService boost::asio::basic_io_object< SocketAcceptorService >::service_type
inherited

The type of the service that will be used to provide I/O operations.

Member Enumeration Documentation

Different ways a socket may be shutdown.

Enumerator
shutdown_receive 
shutdown_send 
shutdown_both 

Constructor & Destructor Documentation

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::basic_socket_acceptor ( boost::asio::io_service io_service)
inlineexplicit

Construct an acceptor without opening it.

This constructor creates an acceptor without opening it to listen for new connections. The open() function must be called before the acceptor can accept new socket connections.

Parameters
io_serviceThe io_service object that the acceptor will use to dispatch handlers for any asynchronous operations performed on the acceptor.
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::basic_socket_acceptor ( boost::asio::io_service io_service,
const protocol_type protocol 
)
inline

Construct an open acceptor.

This constructor creates an acceptor and automatically opens it.

Parameters
io_serviceThe io_service object that the acceptor will use to dispatch handlers for any asynchronous operations performed on the acceptor.
protocolAn object specifying protocol parameters to be used.
Exceptions
boost::system::system_errorThrown on failure.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::basic_socket_acceptor ( boost::asio::io_service io_service,
const endpoint_type endpoint,
bool  reuse_addr = true 
)
inline

Construct an acceptor opened on the given endpoint.

This constructor creates an acceptor and automatically opens it to listen for new connections on the specified endpoint.

Parameters
io_serviceThe io_service object that the acceptor will use to dispatch handlers for any asynchronous operations performed on the acceptor.
endpointAn endpoint on the local machine on which the acceptor will listen for new connections.
reuse_addrWhether the constructor should set the socket option socket_base::reuse_address.
Exceptions
boost::system::system_errorThrown on failure.
Note
This constructor is equivalent to the following code:
basic_socket_acceptor<Protocol> acceptor(io_service);
acceptor.open(endpoint.protocol());
if (reuse_addr)
acceptor.set_option(socket_base::reuse_address(true));
acceptor.bind(endpoint);
acceptor.listen(listen_backlog);

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::basic_socket_acceptor ( boost::asio::io_service io_service,
const protocol_type protocol,
const native_handle_type native_acceptor 
)
inline

Construct a basic_socket_acceptor on an existing native acceptor.

This constructor creates an acceptor object to hold an existing native acceptor.

Parameters
io_serviceThe io_service object that the acceptor will use to dispatch handlers for any asynchronous operations performed on the acceptor.
protocolAn object specifying protocol parameters to be used.
native_acceptorA native acceptor.
Exceptions
boost::system::system_errorThrown on failure.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

Member Function Documentation

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename Protocol1 , typename SocketService >
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::accept ( basic_socket< Protocol1, SocketService > &  peer,
typename enable_if< is_convertible< Protocol, Protocol1 >::value >::type = 0 
)
inline

Accept a new connection.

This function is used to accept a new connection from a peer into the given socket. The function call will block until a new connection has been accepted successfully or an error occurs.

Parameters
peerThe socket into which the new connection will be accepted.
Exceptions
boost::system::system_errorThrown on failure.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::socket socket(io_service);
acceptor.accept(socket);

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename Protocol1 , typename SocketService >
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::accept ( basic_socket< Protocol1, SocketService > &  peer,
boost::system::error_code ec,
typename enable_if< is_convertible< Protocol, Protocol1 >::value >::type = 0 
)
inline

Accept a new connection.

This function is used to accept a new connection from a peer into the given socket. The function call will block until a new connection has been accepted successfully or an error occurs.

Parameters
peerThe socket into which the new connection will be accepted.
ecSet to indicate what error occurred, if any.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::soocket socket(io_service);
acceptor.accept(socket, ec);
if (ec)
{
// An error occurred.
}

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::assign ( const protocol_type protocol,
const native_handle_type native_acceptor 
)
inline
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::assign ( const protocol_type protocol,
const native_handle_type native_acceptor,
boost::system::error_code ec 
)
inline
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::bind ( const endpoint_type endpoint)
inline

Bind the acceptor to the given local endpoint.

This function binds the socket acceptor to the specified endpoint on the local machine.

Parameters
endpointAn endpoint on the local machine to which the socket acceptor will be bound.
Exceptions
boost::system::system_errorThrown on failure.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
acceptor.open(endpoint.protocol());
acceptor.bind(endpoint);

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::bind ( const endpoint_type endpoint,
boost::system::error_code ec 
)
inline

Bind the acceptor to the given local endpoint.

This function binds the socket acceptor to the specified endpoint on the local machine.

Parameters
endpointAn endpoint on the local machine to which the socket acceptor will be bound.
ecSet to indicate what error occurred, if any.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
acceptor.open(endpoint.protocol());
acceptor.bind(endpoint, ec);
if (ec)
{
// An error occurred.
}

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename Protocol1 , typename SocketService , typename AcceptHandler >
boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::BOOST_ASIO_INITFN_RESULT_TYPE ( AcceptHandler  ,
void(boost::system::error_code  
)

Start an asynchronous accept.

This function is used to asynchronously accept a new connection into a socket. The function call always returns immediately.

Parameters
peerThe socket into which the new connection will be accepted. Ownership of the peer object is retained by the caller, which must guarantee that it is valid until the handler is called.
handlerThe handler to be called when the accept operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
void handler(
const boost::system::error_code& error // Result of operation.
);
Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post().
Example
void accept_handler(const boost::system::error_code& error)
{
if (!error)
{
// Accept succeeded.
}
}
...
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::socket socket(io_service);
acceptor.async_accept(socket, accept_handler);
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
SocketService enable_if<is_convertible<Protocol, Protocol1>::value>::type AcceptHandler boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::BOOST_ASIO_INITFN_RESULT_TYPE ( AcceptHandler  ,
void(boost::system::error_code  
)
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
SocketService boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::BOOST_ASIO_MOVE_ARG ( AcceptHandler  )
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
SocketService enable_if<is_convertible<Protocol, Protocol1>::value>::type AcceptHandler SocketService endpoint_type boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::BOOST_ASIO_MOVE_ARG ( AcceptHandler  )
inline
boost::asio::socket_base::BOOST_ASIO_STATIC_CONSTANT ( int  ,
message_peek  = BOOST_ASIO_OS_DEF(MSG_PEEK) 
)
inherited
boost::asio::socket_base::BOOST_ASIO_STATIC_CONSTANT ( int  ,
message_out_of_band  = BOOST_ASIO_OS_DEF(MSG_OOB) 
)
inherited
boost::asio::socket_base::BOOST_ASIO_STATIC_CONSTANT ( int  ,
message_do_not_route  = BOOST_ASIO_OS_DEF(MSG_DONTROUTE) 
)
inherited
boost::asio::socket_base::BOOST_ASIO_STATIC_CONSTANT ( int  ,
message_end_of_record  = BOOST_ASIO_OS_DEF(MSG_EOR) 
)
inherited
boost::asio::socket_base::BOOST_ASIO_STATIC_CONSTANT ( int  ,
max_connections  = BOOST_ASIO_OS_DEF(SOMAXCONN) 
)
inherited

The maximum length of the queue of pending incoming connections.

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::cancel ( )
inline

Cancel all asynchronous operations associated with the acceptor.

This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted error.

Exceptions
boost::system::system_errorThrown on failure.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::cancel ( boost::system::error_code ec)
inline

Cancel all asynchronous operations associated with the acceptor.

This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted error.

Parameters
ecSet to indicate what error occurred, if any.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::close ( )
inline

Close the acceptor.

This function is used to close the acceptor. Any asynchronous accept operations will be cancelled immediately.

A subsequent call to open() is required before the acceptor can again be used to again perform socket accept operations.

Exceptions
boost::system::system_errorThrown on failure.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::close ( boost::system::error_code ec)
inline

Close the acceptor.

This function is used to close the acceptor. Any asynchronous accept operations will be cancelled immediately.

A subsequent call to open() is required before the acceptor can again be used to again perform socket accept operations.

Parameters
ecSet to indicate what error occurred, if any.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::system::error_code ec;
acceptor.close(ec);
if (ec)
{
// An error occurred.
}

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

implementation_type& boost::asio::basic_io_object< SocketAcceptorService >::get_implementation ( )
inlineprotectedinherited

Get the underlying implementation of the I/O object.

Referenced by boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::accept(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::assign(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::basic_socket_acceptor(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::bind(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::BOOST_ASIO_MOVE_ARG(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::cancel(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::close(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::get_option(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::io_control(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::is_open(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::listen(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::local_endpoint(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_handle(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_non_blocking(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::non_blocking(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::open(), and boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::set_option().

const implementation_type& boost::asio::basic_io_object< SocketAcceptorService >::get_implementation ( ) const
inlineprotectedinherited

Get the underlying implementation of the I/O object.

boost::asio::io_service& boost::asio::basic_io_object< SocketAcceptorService >::get_io_service ( )
inlineinherited

Get the io_service associated with the object.

This function may be used to obtain the io_service object that the I/O object uses to dispatch handlers for asynchronous operations.

Returns
A reference to the io_service object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename GettableSocketOption >
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::get_option ( GettableSocketOption &  option)
inline

Get an option from the acceptor.

This function is used to get the current value of an option on the acceptor.

Parameters
optionThe option value to be obtained from the acceptor.
Exceptions
boost::system::system_errorThrown on failure.
See also
GettableSocketOption
boost::asio::socket_base::reuse_address
Example
Getting the value of the SOL_SOCKET/SO_REUSEADDR option:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::acceptor::reuse_address option;
acceptor.get_option(option);
bool is_set = option.get();

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename GettableSocketOption >
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::get_option ( GettableSocketOption &  option,
boost::system::error_code ec 
)
inline

Get an option from the acceptor.

This function is used to get the current value of an option on the acceptor.

Parameters
optionThe option value to be obtained from the acceptor.
ecSet to indicate what error occurred, if any.
See also
GettableSocketOption
boost::asio::socket_base::reuse_address
Example
Getting the value of the SOL_SOCKET/SO_REUSEADDR option:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::acceptor::reuse_address option;
acceptor.get_option(option, ec);
if (ec)
{
// An error occurred.
}
bool is_set = option.get();

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

service_type& boost::asio::basic_io_object< SocketAcceptorService >::get_service ( )
inlineprotectedinherited

Get the service associated with the I/O object.

Referenced by boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::accept(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::assign(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::basic_socket_acceptor(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::bind(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::BOOST_ASIO_MOVE_ARG(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::cancel(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::close(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::get_option(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::io_control(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::is_open(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::listen(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::local_endpoint(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_handle(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_non_blocking(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::non_blocking(), boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::open(), and boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::set_option().

const service_type& boost::asio::basic_io_object< SocketAcceptorService >::get_service ( ) const
inlineprotectedinherited

Get the service associated with the I/O object.

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename IoControlCommand >
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::io_control ( IoControlCommand &  command)
inline

Perform an IO control command on the acceptor.

This function is used to execute an IO control command on the acceptor.

Parameters
commandThe IO control command to be performed on the acceptor.
Exceptions
boost::system::system_errorThrown on failure.
See also
IoControlCommand
boost::asio::socket_base::non_blocking_io
Example
Getting the number of bytes ready to read:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::acceptor::non_blocking_io command(true);
socket.io_control(command);

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename IoControlCommand >
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::io_control ( IoControlCommand &  command,
boost::system::error_code ec 
)
inline

Perform an IO control command on the acceptor.

This function is used to execute an IO control command on the acceptor.

Parameters
commandThe IO control command to be performed on the acceptor.
ecSet to indicate what error occurred, if any.
See also
IoControlCommand
boost::asio::socket_base::non_blocking_io
Example
Getting the number of bytes ready to read:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::acceptor::non_blocking_io command(true);
socket.io_control(command, ec);
if (ec)
{
// An error occurred.
}

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
bool boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::is_open ( ) const
inline
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::listen ( int  backlog = socket_base::max_connections)
inline

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

This function puts the socket acceptor into the state where it may accept new connections.

Parameters
backlogThe maximum length of the queue of pending connections.
Exceptions
boost::system::system_errorThrown on failure.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::listen ( int  backlog,
boost::system::error_code ec 
)
inline

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

This function puts the socket acceptor into the state where it may accept new connections.

Parameters
backlogThe maximum length of the queue of pending connections.
ecSet to indicate what error occurred, if any.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::system::error_code ec;
acceptor.listen(boost::asio::socket_base::max_connections, ec);
if (ec)
{
// An error occurred.
}

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
endpoint_type boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::local_endpoint ( ) const
inline

Get the local endpoint of the acceptor.

This function is used to obtain the locally bound endpoint of the acceptor.

Returns
An object that represents the local endpoint of the acceptor.
Exceptions
boost::system::system_errorThrown on failure.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint();

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
endpoint_type boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::local_endpoint ( boost::system::error_code ec) const
inline

Get the local endpoint of the acceptor.

This function is used to obtain the locally bound endpoint of the acceptor.

Parameters
ecSet to indicate what error occurred, if any.
Returns
An object that represents the local endpoint of the acceptor. Returns a default-constructed endpoint object if an error occurred and the error handler did not throw an exception.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::system::error_code ec;
boost::asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint(ec);
if (ec)
{
// An error occurred.
}

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
native_type boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native ( )
inline

(Deprecated: Use native_handle().) Get the native acceptor representation.

This function may be used to obtain the underlying representation of the acceptor. This is intended to allow access to native acceptor functionality that is not otherwise provided.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
native_handle_type boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_handle ( )
inline

Get the native acceptor representation.

This function may be used to obtain the underlying representation of the acceptor. This is intended to allow access to native acceptor functionality that is not otherwise provided.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
bool boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_non_blocking ( ) const
inline

Gets the non-blocking mode of the native acceptor implementation.

This function is used to retrieve the non-blocking mode of the underlying native acceptor. This mode has no effect on the behaviour of the acceptor object's synchronous operations.

Returns
true if the underlying acceptor is in non-blocking mode and direct system calls may fail with boost::asio::error::would_block (or the equivalent system error).
Note
The current non-blocking mode is cached by the acceptor object. Consequently, the return value may be incorrect if the non-blocking mode was set directly on the native acceptor.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_non_blocking ( bool  mode)
inline

Sets the non-blocking mode of the native acceptor implementation.

This function is used to modify the non-blocking mode of the underlying native acceptor. It has no effect on the behaviour of the acceptor object's synchronous operations.

Parameters
modeIf true, the underlying acceptor is put into non-blocking mode and direct system calls may fail with boost::asio::error::would_block (or the equivalent system error).
Exceptions
boost::system::system_errorThrown on failure. If the mode is false, but the current value of non_blocking() is true, this function fails with boost::asio::error::invalid_argument, as the combination does not make sense.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::native_non_blocking ( bool  mode,
boost::system::error_code ec 
)
inline

Sets the non-blocking mode of the native acceptor implementation.

This function is used to modify the non-blocking mode of the underlying native acceptor. It has no effect on the behaviour of the acceptor object's synchronous operations.

Parameters
modeIf true, the underlying acceptor is put into non-blocking mode and direct system calls may fail with boost::asio::error::would_block (or the equivalent system error).
ecSet to indicate what error occurred, if any. If the mode is false, but the current value of non_blocking() is true, this function fails with boost::asio::error::invalid_argument, as the combination does not make sense.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
bool boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::non_blocking ( ) const
inline

Gets the non-blocking mode of the acceptor.

Returns
true if the acceptor's synchronous operations will fail with boost::asio::error::would_block if they are unable to perform the requested operation immediately. If false, synchronous operations will block until complete.
Note
The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error boost::asio::error::would_block.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::non_blocking ( bool  mode)
inline

Sets the non-blocking mode of the acceptor.

Parameters
modeIf true, the acceptor's synchronous operations will fail with boost::asio::error::would_block if they are unable to perform the requested operation immediately. If false, synchronous operations will block until complete.
Exceptions
boost::system::system_errorThrown on failure.
Note
The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error boost::asio::error::would_block.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::non_blocking ( bool  mode,
boost::system::error_code ec 
)
inline

Sets the non-blocking mode of the acceptor.

Parameters
modeIf true, the acceptor's synchronous operations will fail with boost::asio::error::would_block if they are unable to perform the requested operation immediately. If false, synchronous operations will block until complete.
ecSet to indicate what error occurred, if any.
Note
The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error boost::asio::error::would_block.

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::open ( const protocol_type protocol = protocol_type())
inline

Open the acceptor using the specified protocol.

This function opens the socket acceptor so that it will use the specified protocol.

Parameters
protocolAn object specifying which protocol is to be used.
Exceptions
boost::system::system_errorThrown on failure.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
acceptor.open(boost::asio::ip::tcp::v4());

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::open ( const protocol_type protocol,
boost::system::error_code ec 
)
inline

Open the acceptor using the specified protocol.

This function opens the socket acceptor so that it will use the specified protocol.

Parameters
protocolAn object specifying which protocol is to be used.
ecSet to indicate what error occurred, if any.
Example
boost::asio::ip::tcp::acceptor acceptor(io_service);
acceptor.open(boost::asio::ip::tcp::v4(), ec);
if (ec)
{
// An error occurred.
}

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename SettableSocketOption >
void boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::set_option ( const SettableSocketOption &  option)
inline

Set an option on the acceptor.

This function is used to set an option on the acceptor.

Parameters
optionThe new option value to be set on the acceptor.
Exceptions
boost::system::system_errorThrown on failure.
See also
SettableSocketOption
boost::asio::socket_base::reuse_address boost::asio::socket_base::enable_connection_aborted
Example
Setting the SOL_SOCKET/SO_REUSEADDR option:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::acceptor::reuse_address option(true);
acceptor.set_option(option);

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
template<typename SettableSocketOption >
boost::system::error_code boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::set_option ( const SettableSocketOption &  option,
boost::system::error_code ec 
)
inline

Set an option on the acceptor.

This function is used to set an option on the acceptor.

Parameters
optionThe new option value to be set on the acceptor.
ecSet to indicate what error occurred, if any.
See also
SettableSocketOption
boost::asio::socket_base::reuse_address boost::asio::socket_base::enable_connection_aborted
Example
Setting the SOL_SOCKET/SO_REUSEADDR option:
boost::asio::ip::tcp::acceptor acceptor(io_service);
...
boost::asio::ip::tcp::acceptor::reuse_address option(true);
acceptor.set_option(option, ec);
if (ec)
{
// An error occurred.
}

References boost::asio::basic_io_object< SocketAcceptorService >::get_implementation(), and boost::asio::basic_io_object< SocketAcceptorService >::get_service().

Member Data Documentation

implementation_type boost::asio::basic_io_object< SocketAcceptorService >::implementation
protectedinherited

(Deprecated: Use get_implementation().) The underlying implementation of the I/O object.

template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
SocketService& boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::peer
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
SocketService enable_if<is_convertible<Protocol, Protocol1>::value>::type AcceptHandler SocketService& boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::peer
template<typename Protocol , typename SocketAcceptorService = socket_acceptor_service<Protocol>>
SocketService enable_if<is_convertible<Protocol, Protocol1>::value>::type AcceptHandler SocketService endpoint_type& boost::asio::basic_socket_acceptor< Protocol, SocketAcceptorService >::peer_endpoint
service_type& boost::asio::basic_io_object< SocketAcceptorService >::service
protectedinherited

(Deprecated: Use get_service().) The service associated with the I/O object.

Note
Available only for services that do not support movability.

The documentation for this class was generated from the following file: