asio 0.1.5 Main Page | Class Index | Member Index | Tutorial

basic_socket_acceptor Class Template Reference

The basic_socket_acceptor class template is used for accepting new socket connections. Most applications would use the socket_acceptor typedef. More...

List of all members.

Public Types

typedef Service service_type
 The type of the service that will be used to provide accept operations.

typedef service_type::impl_type impl_type
 The native implementation type of the socket acceptor.

typedef service_type::demuxer_type demuxer_type
 The demuxer type for this asynchronous type.


Public Member Functions

 basic_socket_acceptor (demuxer_type &d)
 Construct an acceptor without opening it.

template<typename Address>  basic_socket_acceptor (demuxer_type &d, const Address &address, int listen_backlog=0)
 Construct an acceptor opened on the given address.

 ~basic_socket_acceptor ()
 Destructor.

demuxer_typedemuxer ()
 Get the demuxer associated with the asynchronous object.

template<typename Protocol> void open (const Protocol &protocol)
 Open the acceptor using the specified protocol.

template<typename Protocol, typename Error_Handler> void open (const Protocol &protocol, Error_Handler error_handler)
 Open the acceptor using the specified protocol.

template<typename Address> void bind (const Address &address)
 Bind the acceptor to the given local address.

template<typename Address, typename Error_Handler> void bind (const Address &address, Error_Handler error_handler)
 Bind the acceptor to the given local address.

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.

impl_type impl ()
 Get the underlying implementation in the native type.

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.

template<typename Address> void get_local_address (Address &address)
 Get the local address of the acceptor.

template<typename Address, typename Error_Handler> void get_local_address (Address &address, Error_Handler error_handler)
 Get the local address of the acceptor.

template<typename Stream> void accept (Stream &peer_socket)
 Accept a new connection.

template<typename Stream, typename Error_Handler> void accept (Stream &peer_socket, Error_Handler error_handler)
 Accept a new connection.

template<typename Stream, typename Handler> void async_accept (Stream &peer_socket, Handler handler)
 Start an asynchronous accept.

template<typename Stream, typename Handler, typename Completion_Context> void async_accept (Stream &peer_socket, Handler handler, Completion_Context context)
 Start an asynchronous accept.

template<typename Stream, typename Address> void accept_address (Stream &peer_socket, Address &peer_address)
 Accept a new connection and obtain the address of the peer.

template<typename Stream, typename Address, typename Error_Handler> void accept_address (Stream &peer_socket, Address &peer_address, Error_Handler error_handler)
 Accept a new connection and obtain the address of the peer.

template<typename Stream, typename Address, typename Handler> void async_accept_address (Stream &peer_socket, Address &peer_address, Handler handler)
 Start an asynchronous accept.

template<typename Stream, typename Address, typename Handler, typename Completion_Context> void async_accept_address (Stream &peer_socket, Address &peer_address, Handler handler, Completion_Context context)
 Start an asynchronous accept.


Private Attributes

service_typeservice_
 The backend service implementation.

impl_type impl_
 The underlying native implementation.


Detailed Description

template<typename Service>
class asio::basic_socket_acceptor< Service >

The basic_socket_acceptor class template is used for accepting new socket connections. Most applications would use the socket_acceptor typedef.


Member Typedef Documentation

typedef Service service_type
 

The type of the service that will be used to provide accept operations.

typedef service_type::impl_type impl_type
 

The native implementation type of the socket acceptor.

typedef service_type::demuxer_type demuxer_type
 

The demuxer type for this asynchronous type.


Constructor & Destructor Documentation

basic_socket_acceptor demuxer_type d  )  [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.

Parameters:
d The demuxer object that the acceptor will use to deliver completions for any asynchronous operations performed on the acceptor.

basic_socket_acceptor demuxer_type d,
const Address &  address,
int  listen_backlog = 0
 

Construct an acceptor opened on the given address.

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

Parameters:
d The demuxer object that the acceptor will use to deliver completions for any asynchronous operations performed on the acceptor.
address An address 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.
Exceptions:
socket_error Thrown on failure.

~basic_socket_acceptor  ) 
 

Destructor.


Member Function Documentation

demuxer_type& demuxer  ) 
 

Get the demuxer associated with the asynchronous object.

This function may be used to obtain the demuxer object that the acceptor uses to deliver completions for asynchronous operations.

Returns:
A reference to the demuxer object that acceptor will use to deliver completion notifications. Ownership is not transferred to the caller.

void open const Protocol &  protocol  ) 
 

Open the acceptor using the specified protocol.

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

Parameters:
protocol An object specifying which protocol is to be used.

void open const Protocol &  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.

Parameters:
protocol An object specifying which protocol is to be used.
error_handler The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void error_handler(
   const asio::socket_error& error // Result of operation
 ); 

void bind const Address &  address  ) 
 

Bind the acceptor to the given local address.

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

Parameters:
address An address on the local machine to which the socket acceptor will be bound.
Exceptions:
socket_error Thrown on failure.

void bind const Address &  address,
Error_Handler  error_handler
 

Bind the acceptor to the given local address.

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

Parameters:
address An address on the local machine to which the socket acceptor will be bound.
error_handler The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void error_handler(
   const asio::socket_error& error // Result of operation
 ); 

void 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.

Parameters:
backlog The maximum length of the queue of pending connections. A value of 0 means use the default queue length.

void 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.

Parameters:
backlog The maximum length of the queue of pending connections. A value of 0 means use the default queue length.
error_handler The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void error_handler(
   const asio::socket_error& error // Result of operation
 ); 

void 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.

impl_type impl  ) 
 

Get the underlying implementation in the native type.

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

void set_option const Option &  option  ) 
 

Set an option on the acceptor.

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

Parameters:
option The new option value to be set on the acceptor.
Exceptions:
socket_error Thrown on failure.

void 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.

Parameters:
option The new option value to be set on the acceptor.
error_handler The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void error_handler(
   const asio::socket_error& error // Result of operation
 ); 

void 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.

Parameters:
option The option value to be obtained from the acceptor.
Exceptions:
socket_error Thrown on failure.

void 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.

Parameters:
option The option value to be obtained from the acceptor.
error_handler The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void error_handler(
   const asio::socket_error& error // Result of operation
 ); 

void get_local_address Address &  address  ) 
 

Get the local address of the acceptor.

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

Parameters:
address An address object that receives the local address of the acceptor.
Exceptions:
socket_error Thrown on failure.

void get_local_address Address &  address,
Error_Handler  error_handler
 

Get the local address of the acceptor.

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

Parameters:
address An address object that receives the local address of the acceptor.
error_handler The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void error_handler(
   const asio::socket_error& error // Result of operation
 ); 

void accept Stream &  peer_socket  ) 
 

Accept a new connection.

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

Parameters:
peer_socket The stream socket into which the new connection will be accepted.
Exceptions:
socket_error Thrown on failure.

void accept Stream &  peer_socket,
Error_Handler  error_handler
 

Accept a new connection.

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

Parameters:
peer_socket The stream socket into which the new connection will be accepted.
error_handler The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void error_handler(
   const asio::socket_error& error // Result of operation
 ); 

void async_accept Stream &  peer_socket,
Handler  handler
 

Start an asynchronous accept.

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

Parameters:
peer_socket The stream socket into which the new connection will be accepted. Ownership of the peer_socket object is retained by the caller, which must guarantee that it is valid until the handler is called.
handler The completion handler to be called when the accept operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void handler(
   const asio::socket_error& error // Result of operation
 ); 

void async_accept Stream &  peer_socket,
Handler  handler,
Completion_Context  context
 

Start an asynchronous accept.

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

Parameters:
peer_socket The stream socket into which the new connection will be accepted. Ownership of the peer_socket object is retained by the caller, which must guarantee that it is valid until the handler is called.
handler The completion handler to be called when the accept operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void handler(
   const asio::socket_error& error // Result of operation
 ); 
context The completion context which controls the number of concurrent invocations of handlers that may be made. Copies will be made of the context object as required, however all copies are equivalent.

void accept_address Stream &  peer_socket,
Address &  peer_address
 

Accept a new connection and obtain the address of the peer.

This function is used to accept a new connection from a peer into the given stream socket, and additionally provide the address of the remote peer. The function call will block until a new connection has been accepted successfully or an error occurs.

Parameters:
peer_socket The stream socket into which the new connection will be accepted.
peer_address An address object which will receive the network address of the remote peer.
Exceptions:
socket_error Thrown on failure.

void accept_address Stream &  peer_socket,
Address &  peer_address,
Error_Handler  error_handler
 

Accept a new connection and obtain the address of the peer.

This function is used to accept a new connection from a peer into the given stream socket, and additionally provide the address of the remote peer. The function call will block until a new connection has been accepted successfully or an error occurs.

Parameters:
peer_socket The stream socket into which the new connection will be accepted.
peer_address An address object which will receive the network address of the remote peer.
error_handler The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void error_handler(
   const asio::socket_error& error // Result of operation
 ); 

void async_accept_address Stream &  peer_socket,
Address &  peer_address,
Handler  handler
 

Start an asynchronous accept.

This function is used to asynchronously accept a new connection into a stream socket, and additionally obtain the address of the remote peer. The function call always returns immediately.

Parameters:
peer_socket The stream socket into which the new connection will be accepted. Ownership of the peer_socket object is retained by the caller, which must guarantee that it is valid until the handler is called.
peer_address An address object into which the address of the remote peer will be written. Ownership of the peer_address object is retained by the caller, which must guarantee that it is valid until the handler is called.
handler The completion handler to be called when the accept operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void handler(
   const asio::socket_error& error // Result of operation
 ); 

void async_accept_address Stream &  peer_socket,
Address &  peer_address,
Handler  handler,
Completion_Context  context
 

Start an asynchronous accept.

This function is used to asynchronously accept a new connection into a stream socket, and additionally obtain the address of the remote peer. The function call always returns immediately.

Parameters:
peer_socket The stream socket into which the new connection will be accepted. Ownership of the peer_socket object is retained by the caller, which must guarantee that it is valid until the handler is called.
peer_address An address object into which the address of the remote peer will be written. Ownership of the peer_address object is retained by the caller, which must guarantee that it is valid until the handler is called.
handler The completion handler to be called when the accept operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void handler(
   const asio::socket_error& error // Result of operation
 ); 
context The completion context which controls the number of concurrent invocations of handlers that may be made. Copies will be made of the context object as required, however all copies are equivalent.


Member Data Documentation

service_type& service_ [private]
 

The backend service implementation.

impl_type impl_ [private]
 

The underlying native implementation.