Reference | Class Hierarchy | Class Index | Member Index |
Inheritance diagram for asio::basic_socket_acceptor< Protocol, Service >:
The basic_socket_acceptor class template is used for accepting new socket connections.
asio::ip::tcp::acceptor acceptor(io_service); asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), port); acceptor.open(endpoint.protocol()); acceptor.set_option(asio::ip::tcp::acceptor::reuse_address(true)); acceptor.bind(endpoint); acceptor.listen();
Public Types | |
typedef Service::native_type | native_type |
The native representation of an acceptor. | |
typedef Protocol | protocol_type |
The protocol type. | |
typedef Protocol::endpoint | endpoint_type |
The endpoint type. | |
typedef asio::error | error_type |
The type used for reporting errors. | |
typedef Service | service_type |
The type of the service that will be used to provide I/O operations. | |
typedef service_type::implementation_type | implementation_type |
The underlying implementation type of I/O object. | |
typedef int | message_flags |
Bitmask type for flags that can be passed to send and receive operations. | |
typedef implementation_defined | broadcast |
Socket option to permit sending of broadcast messages. | |
typedef implementation_defined | do_not_route |
Socket option to prevent routing, use local interfaces only. | |
typedef implementation_defined | keep_alive |
Socket option to send keep-alives. | |
typedef implementation_defined | send_buffer_size |
Socket option for the send buffer size of a socket. | |
typedef implementation_defined | send_low_watermark |
Socket option for the send low watermark. | |
typedef implementation_defined | receive_buffer_size |
Socket option for the receive buffer size of a socket. | |
typedef implementation_defined | receive_low_watermark |
Socket option for the receive low watermark. | |
typedef implementation_defined | reuse_address |
Socket option to allow the socket to be bound to an address that is already in use. | |
typedef implementation_defined | linger |
Socket option to specify whether the socket lingers on close if unsent data is present. | |
typedef implementation_defined | enable_connection_aborted |
Socket option to report aborted connections on accept. | |
typedef implementation_defined | non_blocking_io |
IO control command to set the blocking mode of the socket. | |
typedef implementation_defined | bytes_readable |
IO control command to get the amount of data that can be read without blocking. | |
shutdown_receive = implementation_defined | |
Shutdown the receive side of the socket. | |
shutdown_send = implementation_defined | |
Shutdown the send side of the socket. | |
shutdown_both = implementation_defined | |
Shutdown both send and receive on the socket. | |
enum | shutdown_type { shutdown_receive = implementation_defined, shutdown_send = implementation_defined, shutdown_both = implementation_defined } |
Different ways a socket may be shutdown. More... | |
Public Member Functions | |
basic_socket_acceptor (asio::io_service &io_service) | |
Construct an acceptor without opening it. | |
basic_socket_acceptor (asio::io_service &io_service, const protocol_type &protocol) | |
Construct an open acceptor. | |
basic_socket_acceptor (asio::io_service &io_service, const endpoint_type &endpoint, int listen_backlog=0) | |
Construct an acceptor opened on the given endpoint. | |
basic_socket_acceptor (asio::io_service &io_service, const protocol_type &protocol, const native_type &native_acceptor) | |
Construct a basic_socket_acceptor on an existing native acceptor. | |
void | open (const protocol_type &protocol=protocol_type()) |
Open the acceptor using the specified protocol. | |
template<typename Error_Handler> | |
void | open (const protocol_type &protocol, Error_Handler error_handler) |
Open the acceptor using the specified protocol. | |
void | assign (const protocol_type &protocol, const native_type &native_acceptor) |
Assigns an existing native acceptor to the acceptor. | |
template<typename Error_Handler> | |
void | assign (const protocol_type &protocol, const native_type &native_acceptor, Error_Handler error_handler) |
Assigns an existing native acceptor to the acceptor. | |
void | bind (const endpoint_type &endpoint) |
Bind the acceptor to the given local endpoint. | |
template<typename Error_Handler> | |
void | bind (const endpoint_type &endpoint, Error_Handler error_handler) |
Bind the acceptor to the given local endpoint. | |
void | listen (int backlog=0) |
Place the acceptor into the state where it will listen for new connections. | |
template<typename Error_Handler> | |
void | listen (int backlog, Error_Handler error_handler) |
Place the acceptor into the state where it will listen for new connections. | |
void | close () |
Close the acceptor. | |
template<typename Error_Handler> | |
void | close (Error_Handler error_handler) |
Close the acceptor. | |
native_type | native () |
Get the native acceptor representation. | |
template<typename Option> | |
void | set_option (const Option &option) |
Set an option on the acceptor. | |
template<typename Option, typename Error_Handler> | |
void | set_option (const Option &option, Error_Handler error_handler) |
Set an option on the acceptor. | |
template<typename Option> | |
void | get_option (Option &option) |
Get an option from the acceptor. | |
template<typename Option, typename Error_Handler> | |
void | get_option (Option &option, Error_Handler error_handler) |
Get an option from the acceptor. | |
endpoint_type | local_endpoint () const |
Get the local endpoint of the acceptor. | |
template<typename Error_Handler> | |
endpoint_type | local_endpoint (Error_Handler error_handler) const |
Get the local endpoint of the acceptor. | |
template<typename Socket_Service> | |
void | accept (basic_socket< protocol_type, Socket_Service > &peer) |
Accept a new connection. | |
template<typename Socket_Service, typename Error_Handler> | |
void | accept (basic_socket< protocol_type, Socket_Service > &peer, Error_Handler error_handler) |
Accept a new connection. | |
template<typename Socket_Service, typename Handler> | |
void | async_accept (basic_socket< protocol_type, Socket_Service > &peer, Handler handler) |
Start an asynchronous accept. | |
template<typename Socket_Service> | |
void | accept_endpoint (basic_socket< protocol_type, Socket_Service > &peer, endpoint_type &peer_endpoint) |
Accept a new connection and obtain the endpoint of the peer. | |
template<typename Socket_Service, typename Error_Handler> | |
void | accept_endpoint (basic_socket< protocol_type, Socket_Service > &peer, endpoint_type &peer_endpoint, Error_Handler error_handler) |
Accept a new connection and obtain the endpoint of the peer. | |
template<typename Socket_Service, typename Handler> | |
void | async_accept_endpoint (basic_socket< protocol_type, Socket_Service > &peer, endpoint_type &peer_endpoint, Handler handler) |
Start an asynchronous accept. | |
asio::io_service & | io_service () |
Get the io_service associated with the object. | |
Static Public Attributes | |
static const int | message_peek = implementation_defined |
Peek at incoming data without removing it from the input queue. | |
static const int | message_out_of_band = implementation_defined |
Process out-of-band data. | |
static const int | message_do_not_route = implementation_defined |
Specify that the data should not be subject to routing. |
typedef Service::native_type asio::basic_socket_acceptor< Protocol, Service >::native_type |
The native representation of an acceptor.
typedef Protocol asio::basic_socket_acceptor< Protocol, Service >::protocol_type |
The protocol type.
typedef Protocol::endpoint asio::basic_socket_acceptor< Protocol, Service >::endpoint_type |
The endpoint type.
typedef asio::error asio::basic_socket_acceptor< Protocol, Service >::error_type |
The type used for reporting errors.
typedef Service asio::basic_io_object< Service >::service_type [inherited] |
The type of the service that will be used to provide I/O operations.
typedef service_type::implementation_type asio::basic_io_object< Service >::implementation_type [inherited] |
The underlying implementation type of I/O object.
typedef int asio::socket_base::message_flags [inherited] |
Bitmask type for flags that can be passed to send and receive operations.
typedef implementation_defined asio::socket_base::broadcast [inherited] |
Socket option to permit sending of broadcast messages.
Implements the SOL_SOCKET/SO_BROADCAST socket option.
asio::ip::udp::socket socket(io_service); ... asio::socket_base::broadcast option(true); socket.set_option(option);
asio::ip::udp::socket socket(io_service); ... asio::socket_base::broadcast option; socket.get_option(option); bool is_set = option.get();
typedef implementation_defined asio::socket_base::do_not_route [inherited] |
Socket option to prevent routing, use local interfaces only.
Implements the SOL_SOCKET/SO_DONTROUTE socket option.
asio::ip::udp::socket socket(io_service); ... asio::socket_base::do_not_route option(true); socket.set_option(option);
asio::ip::udp::socket socket(io_service); ... asio::socket_base::do_not_route option; socket.get_option(option); bool is_set = option.get();
typedef implementation_defined asio::socket_base::keep_alive [inherited] |
Socket option to send keep-alives.
Implements the SOL_SOCKET/SO_KEEPALIVE socket option.
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::keep_alive option(true); socket.set_option(option);
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::keep_alive option; socket.get_option(option); bool is_set = option.get();
typedef implementation_defined 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.
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::send_buffer_size option(8192); socket.set_option(option);
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::send_buffer_size option; socket.get_option(option); int size = option.get();
typedef implementation_defined asio::socket_base::send_low_watermark [inherited] |
Socket option for the send low watermark.
Implements the SOL_SOCKET/SO_SNDLOWAT socket option.
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::send_low_watermark option(1024); socket.set_option(option);
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::send_low_watermark option; socket.get_option(option); int size = option.get();
typedef implementation_defined 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.
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::receive_buffer_size option(8192); socket.set_option(option);
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::receive_buffer_size option; socket.get_option(option); int size = option.get();
typedef implementation_defined asio::socket_base::receive_low_watermark [inherited] |
Socket option for the receive low watermark.
Implements the SOL_SOCKET/SO_RCVLOWAT socket option.
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::receive_low_watermark option(1024); socket.set_option(option);
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::receive_low_watermark option; socket.get_option(option); int size = option.get();
typedef implementation_defined 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.
asio::ip::tcp::acceptor acceptor(io_service); ... asio::socket_base::reuse_address option(true); acceptor.set_option(option);
asio::ip::tcp::acceptor acceptor(io_service); ... asio::socket_base::reuse_address option; acceptor.get_option(option); bool is_set = option.get();
typedef implementation_defined 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.
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::linger option(true, 30); socket.set_option(option);
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::linger option; socket.get_option(option); bool is_set = option.enabled(); unsigned short timeout = option.timeout();
typedef implementation_defined 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 asio::error::connection_aborted. By default the option is false.
asio::ip::tcp::acceptor acceptor(io_service); ... asio::socket_base::enable_connection_aborted option(true); acceptor.set_option(option);
asio::ip::tcp::acceptor acceptor(io_service); ... asio::socket_base::enable_connection_aborted option; acceptor.get_option(option); bool is_set = option.get();
typedef implementation_defined asio::socket_base::non_blocking_io [inherited] |
IO control command to set the blocking mode of the socket.
Implements the FIONBIO IO control command.
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::non_blocking_io command(true); socket.io_control(command);
typedef implementation_defined 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.
asio::ip::tcp::socket socket(io_service); ... asio::socket_base::bytes_readable command(true); socket.io_control(command); std::size_t bytes_readable = command.get();
enum asio::socket_base::shutdown_type [inherited] |
asio::basic_socket_acceptor< Protocol, Service >::basic_socket_acceptor | ( | asio::io_service & | io_service | ) | [explicit] |
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.
io_service | The io_service object that the acceptor will use to dispatch handlers for any asynchronous operations performed on the acceptor. |
asio::basic_socket_acceptor< Protocol, Service >::basic_socket_acceptor | ( | asio::io_service & | io_service, | |
const protocol_type & | protocol | |||
) |
Construct an open acceptor.
This constructor creates an acceptor and automatically opens it.
io_service | The io_service object that the acceptor will use to dispatch handlers for any asynchronous operations performed on the acceptor. | |
protocol | An object specifying protocol parameters to be used. |
asio::error | Thrown on failure. |
asio::basic_socket_acceptor< Protocol, Service >::basic_socket_acceptor | ( | asio::io_service & | io_service, | |
const endpoint_type & | endpoint, | |||
int | listen_backlog = 0 | |||
) |
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.
io_service | The io_service object that the acceptor will use to dispatch handlers for any asynchronous operations performed on the acceptor. | |
endpoint | An endpoint on the local machine on which the acceptor will listen for new connections. | |
listen_backlog | The maximum length of the queue of pending connections. A value of 0 means use the default queue length. |
asio::error | Thrown on failure. |
basic_socket_acceptor<Protocol> acceptor(io_service); acceptor.open(endpoint.protocol()); acceptor.bind(endpoint); acceptor.listen(listen_backlog);
asio::basic_socket_acceptor< Protocol, Service >::basic_socket_acceptor | ( | asio::io_service & | io_service, | |
const protocol_type & | protocol, | |||
const native_type & | native_acceptor | |||
) |
Construct a basic_socket_acceptor on an existing native acceptor.
This constructor creates an acceptor object to hold an existing native acceptor.
io_service | The io_service object that the acceptor will use to dispatch handlers for any asynchronous operations performed on the acceptor. | |
protocol | An object specifying protocol parameters to be used. | |
native_acceptor | A native acceptor. |
asio::error | Thrown on failure. |
void asio::basic_socket_acceptor< Protocol, Service >::open | ( | const protocol_type & | protocol = protocol_type() |
) |
Open the acceptor using the specified protocol.
This function opens the socket acceptor so that it will use the specified protocol.
protocol | An object specifying which protocol is to be used. |
asio::ip::tcp::acceptor acceptor(io_service); acceptor.open(asio::ip::tcp::v4());
void asio::basic_socket_acceptor< Protocol, Service >::open | ( | const protocol_type & | protocol, | |
Error_Handler | error_handler | |||
) |
Open the acceptor using the specified protocol.
This function opens the socket acceptor so that it will use the specified protocol.
protocol | An object specifying which protocol is to be used. | |
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); asio::error error; acceptor.open(asio::ip::tcp::v4(), asio::assign_error(error)); if (error) { // An error occurred. }
void asio::basic_socket_acceptor< Protocol, Service >::assign | ( | const protocol_type & | protocol, | |
const native_type & | native_acceptor | |||
) |
Assigns an existing native acceptor to the acceptor.
void asio::basic_socket_acceptor< Protocol, Service >::assign | ( | const protocol_type & | protocol, | |
const native_type & | native_acceptor, | |||
Error_Handler | error_handler | |||
) |
Assigns an existing native acceptor to the acceptor.
void asio::basic_socket_acceptor< Protocol, Service >::bind | ( | const endpoint_type & | endpoint | ) |
Bind the acceptor to the given local endpoint.
This function binds the socket acceptor to the specified endpoint on the local machine.
endpoint | An endpoint on the local machine to which the socket acceptor will be bound. |
asio::error | Thrown on failure. |
asio::ip::tcp::acceptor acceptor(io_service); acceptor.open(asio::ip::tcp::v4()); acceptor.bind(asio::ip::tcp::endpoint(12345));
void asio::basic_socket_acceptor< Protocol, Service >::bind | ( | const endpoint_type & | endpoint, | |
Error_Handler | error_handler | |||
) |
Bind the acceptor to the given local endpoint.
This function binds the socket acceptor to the specified endpoint on the local machine.
endpoint | An endpoint on the local machine to which the socket acceptor will be bound. | |
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); acceptor.open(asio::ip::tcp::v4()); asio::error error; acceptor.bind(asio::ip::tcp::endpoint(12345), asio::assign_error(error)); if (error) { // An error occurred. }
void asio::basic_socket_acceptor< Protocol, Service >::listen | ( | int | backlog = 0 |
) |
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.
backlog | The maximum length of the queue of pending connections. A value of 0 means use the default queue length. |
void asio::basic_socket_acceptor< Protocol, Service >::listen | ( | int | backlog, | |
Error_Handler | error_handler | |||
) |
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.
backlog | The maximum length of the queue of pending connections. A value of 0 means use the default queue length. | |
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::error error; acceptor.listen(0, asio::assign_error(error)); if (error) { // An error occurred. }
void asio::basic_socket_acceptor< Protocol, Service >::close | ( | ) |
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.
asio::error | Thrown on failure. |
void asio::basic_socket_acceptor< Protocol, Service >::close | ( | Error_Handler | error_handler | ) |
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.
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::error error; acceptor.close(asio::assign_error(error)); if (error) { // An error occurred. }
native_type asio::basic_socket_acceptor< Protocol, Service >::native | ( | ) |
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.
void asio::basic_socket_acceptor< Protocol, Service >::set_option | ( | const Option & | option | ) |
Set an option on the acceptor.
This function is used to set an option on the acceptor.
option | The new option value to be set on the acceptor. |
asio::error | Thrown on failure. |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::acceptor::reuse_address option(true); acceptor.set_option(option);
void asio::basic_socket_acceptor< Protocol, Service >::set_option | ( | const Option & | option, | |
Error_Handler | error_handler | |||
) |
Set an option on the acceptor.
This function is used to set an option on the acceptor.
option | The new option value to be set on the acceptor. | |
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::acceptor::reuse_address option(true); asio::error error; acceptor.set_option(option, asio::assign_error(error)); if (error) { // An error occurred. }
void asio::basic_socket_acceptor< Protocol, Service >::get_option | ( | Option & | option | ) |
Get an option from the acceptor.
This function is used to get the current value of an option on the acceptor.
option | The option value to be obtained from the acceptor. |
asio::error | Thrown on failure. |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::acceptor::reuse_address option; acceptor.get_option(option); bool is_set = option.get();
void asio::basic_socket_acceptor< Protocol, Service >::get_option | ( | Option & | option, | |
Error_Handler | error_handler | |||
) |
Get an option from the acceptor.
This function is used to get the current value of an option on the acceptor.
option | The option value to be obtained from the acceptor. | |
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::acceptor::reuse_address option; asio::error error; acceptor.get_option(option, asio::assign_error(error)); if (error) { // An error occurred. } bool is_set = option.get();
endpoint_type asio::basic_socket_acceptor< Protocol, Service >::local_endpoint | ( | ) | const |
Get the local endpoint of the acceptor.
This function is used to obtain the locally bound endpoint of the acceptor.
asio::error | Thrown on failure. |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint();
endpoint_type asio::basic_socket_acceptor< Protocol, Service >::local_endpoint | ( | Error_Handler | error_handler | ) | const |
Get the local endpoint of the acceptor.
This function is used to obtain the locally bound endpoint of the acceptor.
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::error error; asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint(asio::assign_error(error)); if (error) { // An error occurred. }
void asio::basic_socket_acceptor< Protocol, Service >::accept | ( | basic_socket< protocol_type, Socket_Service > & | peer | ) |
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.
peer | The socket into which the new connection will be accepted. |
asio::error | Thrown on failure. |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::socket socket(io_service); acceptor.accept(socket);
void asio::basic_socket_acceptor< Protocol, Service >::accept | ( | basic_socket< protocol_type, Socket_Service > & | peer, | |
Error_Handler | error_handler | |||
) |
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.
peer | The socket into which the new connection will be accepted. | |
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::soocket socket(io_service); asio::error error; acceptor.accept(socket, asio::assign_error(error)); if (error) { // An error occurred. }
void asio::basic_socket_acceptor< Protocol, Service >::async_accept | ( | basic_socket< protocol_type, Socket_Service > & | peer, | |
Handler | handler | |||
) |
Start an asynchronous accept.
This function is used to asynchronously accept a new connection into a socket. The function call always returns immediately.
peer | The 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. | |
handler | The 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 asio::error& error // Result of operation ); |
void accept_handler(const asio::error& error) { if (!error) { // Accept succeeded. } } ... asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::socket socket(io_service); acceptor.async_accept(socket, accept_handler);
void asio::basic_socket_acceptor< Protocol, Service >::accept_endpoint | ( | basic_socket< protocol_type, Socket_Service > & | peer, | |
endpoint_type & | peer_endpoint | |||
) |
Accept a new connection and obtain the endpoint of the peer.
This function is used to accept a new connection from a peer into the given socket, and additionally provide the endpoint of the remote peer. The function call will block until a new connection has been accepted successfully or an error occurs.
peer | The socket into which the new connection will be accepted. | |
peer_endpoint | An endpoint object which will receive the endpoint of the remote peer. |
asio::error | Thrown on failure. |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::socket socket(io_service); asio::ip::tcp::endpoint endpoint; acceptor.accept_endpoint(socket, endpoint);
void asio::basic_socket_acceptor< Protocol, Service >::accept_endpoint | ( | basic_socket< protocol_type, Socket_Service > & | peer, | |
endpoint_type & | peer_endpoint, | |||
Error_Handler | error_handler | |||
) |
Accept a new connection and obtain the endpoint of the peer.
This function is used to accept a new connection from a peer into the given socket, and additionally provide the endpoint of the remote peer. The function call will block until a new connection has been accepted successfully or an error occurs.
peer | The socket into which the new connection will be accepted. | |
peer_endpoint | An endpoint object which will receive the endpoint of the remote peer. | |
error_handler | A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be: void error_handler( const asio::error& error // Result of operation ); |
asio::ip::tcp::acceptor acceptor(io_service); ... asio::ip::tcp::socket socket(io_service); asio::ip::tcp::endpoint endpoint; asio::error error; acceptor.accept_endpoint(socket, endpoint, asio::assign_error(error)); if (error) { // An error occurred. }
void asio::basic_socket_acceptor< Protocol, Service >::async_accept_endpoint | ( | basic_socket< protocol_type, Socket_Service > & | peer, | |
endpoint_type & | peer_endpoint, | |||
Handler | handler | |||
) |
Start an asynchronous accept.
This function is used to asynchronously accept a new connection into a socket, and additionally obtain the endpoint of the remote peer. The function call always returns immediately.
peer | The 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. | |
peer_endpoint | An endpoint object into which the endpoint of the remote peer will be written. Ownership of the peer_endpoint object is retained by the caller, which must guarantee that it is valid until the handler is called. | |
handler | The 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 asio::error& error // Result of operation ); |
asio::io_service& asio::basic_io_object< Service >::io_service | ( | ) | [inherited] |
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.
const int asio::socket_base::message_peek = implementation_defined [static, inherited] |
Peek at incoming data without removing it from the input queue.
const int asio::socket_base::message_out_of_band = implementation_defined [static, inherited] |
Process out-of-band data.
const int asio::socket_base::message_do_not_route = implementation_defined [static, inherited] |
Specify that the data should not be subject to routing.