Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Asynch_Acceptor Class Template Reference

This class is an example of the Acceptor Pattern. This class will accept new connections and create new HANDLER to handle the new connections. More...

#include <Asynch_Acceptor.h>

Inheritance diagram for ACE_Asynch_Acceptor:

Inheritance graph
[legend]
Collaboration diagram for ACE_Asynch_Acceptor:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Asynch_Acceptor (void)
 A do nothing constructor. More...

virtual ~ACE_Asynch_Acceptor (void)
 Virtual destruction. More...

virtual int open (const ACE_INET_Addr &address, size_t bytes_to_read=0, int pass_addresses=0, int backlog=ACE_DEFAULT_BACKLOG, int reuse_addr=1, ACE_Proactor *proactor=0, int validate_new_connection=0, int reissue_accept=1, int number_of_initial_accepts=-1)
virtual ACE_HANDLE get_handle (void) const
 Get the underlying handle. More...

virtual void set_handle (ACE_HANDLE handle)
virtual int accept (size_t bytes_to_read=0, const void *act=0)
 This initiates a new asynchronous accept operation. More...

virtual int cancel (void)
virtual int validate_connection (const ACE_Asynch_Accept::Result &result, const ACE_INET_Addr &remote, const ACE_INET_Addr &local)
virtual int validate_new_connection (const ACE_INET_Addr &remote_address)
virtual int should_reissue_accept (void)
virtual int pass_addresses (void) const
 Get flag that indicates if parsing and passing of addresses to the service_handler is necessary. More...

virtual void pass_addresses (int new_value)
 Set flag that indicates if parsing and passing of addresses to the service_handler is necessary. More...

virtual int validate_new_connection (void) const
 Get flag that indicates if address validation is required. More...

virtual void validate_new_connection (int new_value)
 Set flag that indicates if address validation is required. More...

virtual int reissue_accept (void) const
 Get flag that indicates if a new accept should be reissued when a accept completes. More...

virtual void reissue_accept (int new_value)
 Set flag that indicates if a new accept should be reissued when a accept completes. More...

virtual size_t bytes_to_read (void) const
 Get bytes to be read with the <accept> call. More...

virtual void bytes_to_read (size_t new_value)
 Set bytes to be read with the <accept> call. More...


Static Public Methods

size_t address_size (void)
 This is required by the AcceptEx call. More...


Protected Methods

virtual void handle_accept (const ACE_Asynch_Accept::Result &result)
 This is called when an outstanding accept completes. More...

ACE_HANDLE handle (void) const
 Return the listen handle. More...

void handle (ACE_HANDLE h)
 Set the listen handle. More...

void parse_address (const ACE_Asynch_Accept::Result &result, ACE_INET_Addr &remote_address, ACE_INET_Addr &local_address)
 This parses the address from read buffer. More...

ACE_Asynch_Acceptasynch_accept (void)
 Return the asynch accept object. More...

virtual HANDLER * make_handler (void)

Private Attributes

ACE_HANDLE listen_handle_
 Handle used to listen for new connections. More...

ACE_Asynch_Accept asynch_accept_
 <Asynch_Accept> used to make life easier :-). More...

int pass_addresses_
 Flag that indicates if parsing of addresses is necessary. More...

int validate_new_connection_
 Flag that indicates if address validation is required. More...

int reissue_accept_
 Flag that indicates if a new accept should be reissued when a accept completes. More...

size_t bytes_to_read_
 Bytes to be read with the <accept> call. More...


Detailed Description

template<class HANDLER>
class ACE_Asynch_Acceptor< HANDLER >

This class is an example of the Acceptor Pattern. This class will accept new connections and create new HANDLER to handle the new connections.

Unlike the <ACE_Acceptor>, however, this class is designed to be used asynchronously.

Definition at line 44 of file Asynch_Acceptor.h.


Constructor & Destructor Documentation

template<class HANDLER>
ACE_Asynch_Acceptor< HANDLER >::ACE_Asynch_Acceptor void   
 

A do nothing constructor.

Definition at line 27 of file Asynch_Acceptor.cpp.

00028   : listen_handle_ (ACE_INVALID_HANDLE),
00029     pass_addresses_ (0),
00030     validate_new_connection_ (0),
00031     reissue_accept_ (1),
00032     bytes_to_read_ (0)
00033 {
00034 }

template<class HANDLER>
ACE_Asynch_Acceptor< HANDLER >::~ACE_Asynch_Acceptor void    [virtual]
 

Virtual destruction.

Definition at line 37 of file Asynch_Acceptor.cpp.

00038 {
00039   //this->asynch_accept_.close ();
00040 
00041   // Close down the listen socket
00042   // if (this->listen_handle_ != ACE_INVALID_HANDLE)
00043   //   ACE_OS::closesocket (this->listen_handle_);
00044 }


Member Function Documentation

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::accept size_t    bytes_to_read = 0,
const void *    act = 0
[virtual]
 

This initiates a new asynchronous accept operation.

You need only call this method if the reissue_accept argument passed to open() was 0.

Definition at line 162 of file Asynch_Acceptor.cpp.

References ACE_Asynch_Accept::accept, ACE_NEW_RETURN, ACE_TRACE, address_size, asynch_accept_, bytes_to_read, and ACE_Message_Block::release.

Referenced by handle_accept, and open.

00163 {
00164   ACE_TRACE ("ACE_Asynch_Acceptor<>::accept");
00165 
00166   ACE_Message_Block *message_block = 0;
00167   size_t space_needed = bytes_to_read + 2 * this->address_size ();
00168 
00169   // Create a new message block big enough for the addresses and data
00170   ACE_NEW_RETURN (message_block,
00171                   ACE_Message_Block (space_needed),
00172                   -1);
00173 
00174   // Initiate asynchronous accepts
00175   if (this->asynch_accept_.accept (*message_block,
00176                                    bytes_to_read,
00177                                    ACE_INVALID_HANDLE,
00178                                    act) == -1)
00179     {
00180       // Cleanup on error
00181       message_block->release ();
00182       return -1;
00183     }
00184   return 0;
00185 }

template<class HANDLER>
size_t ACE_Asynch_Acceptor< HANDLER >::address_size void    [static]
 

This is required by the AcceptEx call.

Definition at line 401 of file Asynch_Acceptor.cpp.

Referenced by accept.

00402 {
00403   return sizeof (sockaddr) + sizeof (sockaddr_in);
00404 }

template<class HANDLER>
ACE_Asynch_Accept & ACE_Asynch_Acceptor< HANDLER >::asynch_accept void    [protected]
 

Return the asynch accept object.

Definition at line 383 of file Asynch_Acceptor.cpp.

References asynch_accept_.

00384 {
00385   return this->asynch_accept_;
00386 }

template<class HANDLER>
void ACE_Asynch_Acceptor< HANDLER >::bytes_to_read size_t    new_value [virtual]
 

Set bytes to be read with the <accept> call.

Definition at line 449 of file Asynch_Acceptor.cpp.

References bytes_to_read_.

00450 {
00451   this->bytes_to_read_ = new_value;
00452 }

template<class HANDLER>
size_t ACE_Asynch_Acceptor< HANDLER >::bytes_to_read void    const [virtual]
 

Get bytes to be read with the <accept> call.

Definition at line 443 of file Asynch_Acceptor.cpp.

References bytes_to_read_.

Referenced by accept, and open.

00444 {
00445   return this->bytes_to_read_;
00446 }

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::cancel void    [virtual]
 

Cancels all pending accepts operations issued by this object.

Note:
On Windows, only accept operations initiated by the calling thread are canceled.

Definition at line 306 of file Asynch_Acceptor.cpp.

References ACE_TRACE, asynch_accept_, ACE_Asynch_Operation::cancel, and listen_handle_.

00307 {
00308   ACE_TRACE ("ACE_Asynch_Acceptor<>::cancel");
00309 
00310   // All I/O operations that are canceled will complete with the error
00311   // ERROR_OPERATION_ABORTED. All completion notifications for the I/O
00312   // operations will occur normally.
00313 #if (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) \
00314     && (   (defined (_MSC_VER) && (_MSC_VER > 1020)) \
00315         || (defined (__BORLANDC__) && (__BORLANDC__ >= 0x530)))
00316   return (int) ::CancelIo (this->listen_handle_);
00317 #else
00318   //ACE_NOTSUP_RETURN (-1);
00319   // Supported now
00320   return this->asynch_accept_.cancel();
00321 
00322 #endif /* (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) && ((defined (_MSC_VER) && (_MSC_VER > 1020)) || (defined (__BORLANDC__) && (__BORLANDC__ >= 0x530))) */
00323 }

template<class HANDLER>
ACE_HANDLE ACE_Asynch_Acceptor< HANDLER >::get_handle void    const [virtual]
 

Get the underlying handle.

Definition at line 156 of file Asynch_Acceptor.cpp.

References listen_handle_.

00157 {
00158   return this->listen_handle_;
00159 }

template<class HANDLER>
void ACE_Asynch_Acceptor< HANDLER >::handle ACE_HANDLE    h [protected, virtual]
 

Set the listen handle.

Reimplemented from ACE_Handler.

Definition at line 377 of file Asynch_Acceptor.cpp.

References ACE_Handler::handle.

00378 {
00379   ACE_Handler::handle (h);
00380 }

template<class HANDLER>
ACE_HANDLE ACE_Asynch_Acceptor< HANDLER >::handle void    const [protected, virtual]
 

Return the listen handle.

Reimplemented from ACE_Handler.

Definition at line 371 of file Asynch_Acceptor.cpp.

References listen_handle_.

00372 {
00373   return this->listen_handle_;
00374 }

template<class HANDLER>
void ACE_Asynch_Acceptor< HANDLER >::handle_accept const ACE_Asynch_Accept::Result   result [protected, virtual]
 

This is called when an outstanding accept completes.

Reimplemented from ACE_Handler.

Definition at line 188 of file Asynch_Acceptor.cpp.

References accept, ACE_Asynch_Accept::Result::accept_handle, ACE_TRACE, ACE_Asynch_Result::act, ACE_OS::closesocket, listen_handle_, make_handler, ACE_Asynch_Accept::Result::message_block, parse_address, pass_addresses_, ACE_Message_Block::release, ACE_OS::setsockopt, should_reissue_accept, ACE_Asynch_Result::success, validate_connection, validate_new_connection, and validate_new_connection_.

00189 {
00190 #if (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) || defined (ACE_HAS_AIO_CALLS)
00191 
00192   ACE_TRACE ("ACE_Asynch_Acceptor<>::handle_accept");
00193 
00194   // Variable for error tracking
00195   int error = 0;
00196 
00197   // If the asynchronous accept fails.
00198   if (!result.success () ||
00199       result.accept_handle() == ACE_INVALID_HANDLE )
00200     {
00201       error = 1;
00202     }
00203 
00204 #if !defined (ACE_HAS_AIO_CALLS)
00205   // In order to use accept handle with other Window Sockets 1.1
00206   // functions, we call the setsockopt function with the
00207   // SO_UPDATE_ACCEPT_CONTEXT option. This option initializes the
00208   // socket so that other Windows Sockets routines to access the
00209   // socket correctly.
00210   if (!error &&
00211       ACE_OS::setsockopt (result.accept_handle (),
00212                           SOL_SOCKET,
00213                           SO_UPDATE_ACCEPT_CONTEXT,
00214                           (char *) &this->listen_handle_,
00215                           sizeof (this->listen_handle_)) == -1)
00216     {
00217       error = 1;
00218     }
00219 #endif /* ACE_HAS_AIO_CALLS */
00220 
00221   // Parse address.
00222   ACE_INET_Addr local_address;
00223   ACE_INET_Addr remote_address;
00224   if (!error &&
00225       (this->validate_new_connection_ || this->pass_addresses_))
00226     // Parse the addresses.
00227     this->parse_address (result,
00228                          remote_address,
00229                          local_address);
00230 
00231   // Validate remote address
00232   if (!error &&
00233       this->validate_new_connection_ &&
00234       (this->validate_connection (result, remote_address, local_address) == -1
00235        || this->validate_new_connection (remote_address) == -1))
00236     {
00237       error = 1;
00238     }
00239 
00240   HANDLER *new_handler = 0;
00241   if (!error)
00242     {
00243       // The Template method
00244       new_handler = this->make_handler ();
00245       if (new_handler == 0)
00246         {
00247           error = 1;
00248         }
00249     }
00250 
00251   // If no errors
00252   if (!error)
00253     {
00254       // Update the Proactor.
00255       new_handler->proactor (this->proactor ());
00256 
00257       // Pass the addresses
00258       if (this->pass_addresses_)
00259         new_handler->addresses (remote_address,
00260                                 local_address);
00261 
00262       // Pass the ACT
00263       if (result.act () != 0)
00264         new_handler->act (result.act ());
00265 
00266       // Set up the handler's new handle value
00267       new_handler->handle (result.accept_handle ());
00268 
00269       // Initiate the handler
00270       new_handler->open (result.accept_handle (),
00271                          result.message_block ());
00272     }
00273 
00274   // On failure, no choice but to close the socket
00275   if (error &&
00276       result.accept_handle() != ACE_INVALID_HANDLE )
00277     ACE_OS::closesocket (result.accept_handle ());
00278 
00279   // Delete the dynamically allocated message_block
00280   result.message_block ().release ();
00281 
00282   // Start off another asynchronous accept to keep the backlog going
00283   if (this->should_reissue_accept ())
00284     this->accept (this->bytes_to_read_);
00285 #endif /* (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) || defined (ACE_HAS_AIO_CALLS */
00286 }

template<class HANDLER>
HANDLER * ACE_Asynch_Acceptor< HANDLER >::make_handler void    [protected, virtual]
 

This is the template method used to create new handler. Subclasses must overwrite this method if a new handler creation strategy is required.

Definition at line 389 of file Asynch_Acceptor.cpp.

References ACE_NEW_RETURN.

Referenced by handle_accept.

00390 {
00391   // Default behavior
00392   HANDLER *handler = 0;
00393   ACE_NEW_RETURN (handler,
00394                   HANDLER,
00395                   0);
00396   return handler;
00397 }

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::open const ACE_INET_Addr   address,
size_t    bytes_to_read = 0,
int    pass_addresses = 0,
int    backlog = ACE_DEFAULT_BACKLOG,
int    reuse_addr = 1,
ACE_Proactor   proactor = 0,
int    validate_new_connection = 0,
int    reissue_accept = 1,
int    number_of_initial_accepts = -1
[virtual]
 

open starts one or more asynchronous accept requests on a address. Each accept operation may optionally read an initial buffer from the new connection when accepted.

Parameters:
address  The address to listen/accept connections on. If the address does not specify a port, a random port is selected and bound.
bytes_to_read  Optional, specifies the maximum number of bytes to read with the accept. The buffer for the initial data is allocated internally and passed to the ACE_Service_Handler::open() hook method. It is legitimate only during the open() method and must be copied if required after open() returns. This pre-read function works only on Windows.
pass_addresses  Optional, a non-zero value indicates that the local and peer addresses should be passed to the associated ACE_Service_Handler::addresses() method after any call to validate_new_connection() and prior to the open() hook method call.
backlog  Optional, defaulting to ACE_DEFAULT_BACKLOG (which can be adjusted in your platform's config.h file). Specifies the listening backlog for the listening socket.
reuse_addr  Optional, indicates whether the SO_REUSEADDR option is set on the listening socket or not.
proactor  Optional, pointer to the ACE_Proactor to use for demultiplexing asynchronous accepts. If 0, the process's singleton ACE_Proactor is used.
validate_new_connection  Optional, if non-zero, this object's validate_connection() method is called after the accept completes, but before the service handler's open() hook method is called. If validate_connection() returns -1, the newly-accepted socket is immediately closed, and the addresses() method is not called.
reissue_accept  Optional, if non-zero (the default), a new asynchronous accept operation is started after each completion, whether the completion is for success or failure, and whether or not a successfully-accepted connection is subsequently refused.
number_of_initial_accepts  Optional, the number of asynchronous accepts that are started immediately. If -1 (the default), the value of backlog is used.
Note:
On Windows, the peer address is only available at the time the connection is accepted. Therefore, if you require the peer address on Windows, do not rely on the ACE_SOCK::get_remote_addr() method - it won't work. You must supply a non-zero value for pass_addresses and obtain the peer address in the ACE_Service_Handler::addresses() method.
See also:
ACE_INET_Addr , ACE_Service_Handler

Definition at line 47 of file Asynch_Acceptor.cpp.

References accept, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, asynch_accept_, ACE_OS::bind, ACE_Sock_Connect::bind_port, bytes_to_read, bytes_to_read_, ACE_INET_Addr::get_addr, ACE_Addr::get_size, ACE_Addr::get_type, ACE_OS::listen, listen_handle_, LM_ERROR, ACE_Asynch_Accept::open, pass_addresses, pass_addresses_, ACE_Handler::proactor, reissue_accept, reissue_accept_, ACE_OS::setsockopt, ACE_OS::socket, validate_new_connection, and validate_new_connection_.

00056 {
00057   ACE_TRACE ("ACE_Asynch_Acceptor<>::open");
00058 
00059   this->proactor (proactor);
00060   this->pass_addresses_ = pass_addresses;
00061   this->bytes_to_read_ = bytes_to_read;
00062   this->validate_new_connection_ = validate_new_connection;
00063   this->reissue_accept_ = reissue_accept;
00064 
00065   // Create the listener socket
00066   this->listen_handle_ = ACE_OS::socket (address.get_type (), SOCK_STREAM, 0);
00067   if (this->listen_handle_ == ACE_INVALID_HANDLE)
00068     ACE_ERROR_RETURN ((LM_ERROR,
00069                        ACE_LIB_TEXT ("%p\n"),
00070                        ACE_LIB_TEXT ("ACE_OS::socket")),
00071                       -1);
00072   // Initialize the ACE_Asynch_Accept
00073   if (this->asynch_accept_.open (*this,
00074                                  this->listen_handle_,
00075                                  0,
00076                                  this->proactor ()) == -1)
00077     ACE_ERROR_RETURN ((LM_ERROR,
00078                        ACE_LIB_TEXT ("%p\n"),
00079                        ACE_LIB_TEXT ("ACE_Asynch_Accept::open")),
00080                       -1);
00081   if (reuse_addr)
00082     {
00083       // Reuse the address
00084       int one = 1;
00085       if (ACE_OS::setsockopt (this->listen_handle_,
00086                               SOL_SOCKET,
00087                               SO_REUSEADDR,
00088                               (const char*) &one,
00089                               sizeof one) == -1)
00090         ACE_ERROR_RETURN ((LM_ERROR,
00091                            ACE_LIB_TEXT ("%p\n"),
00092                            ACE_LIB_TEXT ("ACE_OS::setsockopt")),
00093                           -1);
00094     }
00095 
00096   // If port is not specified, bind to any port.
00097   static ACE_INET_Addr sa (ACE_sap_any_cast (const ACE_INET_Addr &));
00098 
00099   if (address == sa &&
00100       ACE_Sock_Connect::bind_port (this->listen_handle_) == -1)
00101     ACE_ERROR_RETURN ((LM_ERROR,
00102                        ACE_LIB_TEXT ("%p\n"),
00103                        ACE_LIB_TEXT ("ACE::bind_port")),
00104                       -1);
00105 
00106   // Bind to the specified port.
00107   if (ACE_OS::bind (this->listen_handle_,
00108                     ACE_reinterpret_cast (sockaddr *,
00109                                           address.get_addr ()),
00110                     address.get_size ()) == -1)
00111     ACE_ERROR_RETURN ((LM_ERROR,
00112                        "%p\n",
00113                        "ACE_OS::bind"),
00114                       -1);
00115 
00116   // Start listening.
00117   if (ACE_OS::listen (this->listen_handle_, backlog) == -1)
00118     ACE_ERROR_RETURN ((LM_ERROR,
00119                        "%p\n",
00120                        "ACE_OS::listen"),
00121                       -1);
00122 
00123   // For the number of <intial_accepts>.
00124   if (number_of_initial_accepts == -1)
00125     number_of_initial_accepts = backlog;
00126 
00127   for (int i = 0; i < number_of_initial_accepts; i++)
00128     // Initiate accepts.
00129     if (this->accept (bytes_to_read) == -1)
00130       ACE_ERROR_RETURN ((LM_ERROR,
00131                          "%p\n",
00132                          "ACE_Asynch_Acceptor::accept"),
00133                         -1);
00134   return 0;
00135 }

template<class HANDLER>
void ACE_Asynch_Acceptor< HANDLER >::parse_address const ACE_Asynch_Accept::Result   result,
ACE_INET_Addr   remote_address,
ACE_INET_Addr   local_address
[protected]
 

This parses the address from read buffer.

Definition at line 326 of file Asynch_Acceptor.cpp.

References ACE_Asynch_Accept::Result::accept_handle, ACE_TRACE, ENOTSUP, ACE_SOCK::get_local_addr, ACE_SOCK::get_remote_addr, ACE_Asynch_Accept::Result::message_block, ACE_Message_Block::rd_ptr, and ACE_INET_Addr::set.

Referenced by handle_accept.

00330 {
00331   ACE_TRACE ("ACE_Asynch_Acceptor<>::parse_address");
00332 
00333 #if defined (ACE_HAS_AIO_CALLS)
00334 
00335   // Use an ACE_SOCK to get the addresses - it knows how to deal with
00336   // ACE_INET_Addr objects and get IPv4/v6 addresses.
00337   ACE_SOCK_Stream str (result.accept_handle ());
00338   str.get_local_addr (local_address);
00339   str.get_remote_addr (remote_address);
00340 
00341 #elif (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00342 
00343   ACE_Message_Block &message_block = result.message_block ();
00344 
00345   sockaddr *local_addr = 0;
00346   sockaddr *remote_addr = 0;
00347   int local_size = 0;
00348   int remote_size = 0;
00349 
00350   ::GetAcceptExSockaddrs (message_block.rd_ptr (),
00351                           ACE_static_cast (DWORD, this->bytes_to_read_),
00352                           ACE_static_cast (DWORD, this->address_size ()),
00353                           ACE_static_cast (DWORD, this->address_size ()),
00354                           &local_addr,
00355                           &local_size,
00356                           &remote_addr,
00357                           &remote_size);
00358 
00359   local_address.set (ACE_reinterpret_cast (sockaddr_in *, local_addr),
00360                      local_size);
00361   remote_address.set (ACE_reinterpret_cast (sockaddr_in *, remote_addr),
00362                       remote_size);
00363 #else
00364   // just in case
00365   errno = ENOTSUP;
00366 #endif /* (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) */
00367   return;
00368 }

template<class HANDLER>
void ACE_Asynch_Acceptor< HANDLER >::pass_addresses int    new_value [virtual]
 

Set flag that indicates if parsing and passing of addresses to the service_handler is necessary.

Definition at line 413 of file Asynch_Acceptor.cpp.

References pass_addresses_.

00414 {
00415   this->pass_addresses_ = new_value;
00416 }

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::pass_addresses void    const [virtual]
 

Get flag that indicates if parsing and passing of addresses to the service_handler is necessary.

Definition at line 407 of file Asynch_Acceptor.cpp.

References pass_addresses_.

Referenced by open.

00408 {
00409   return this->pass_addresses_;
00410 }

template<class HANDLER>
void ACE_Asynch_Acceptor< HANDLER >::reissue_accept int    new_value [virtual]
 

Set flag that indicates if a new accept should be reissued when a accept completes.

Definition at line 437 of file Asynch_Acceptor.cpp.

References reissue_accept_.

00438 {
00439   this->reissue_accept_ = new_value;
00440 }

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::reissue_accept void    const [virtual]
 

Get flag that indicates if a new accept should be reissued when a accept completes.

Definition at line 431 of file Asynch_Acceptor.cpp.

References reissue_accept_.

Referenced by open.

00432 {
00433   return this->reissue_accept_;
00434 }

template<class HANDLER>
void ACE_Asynch_Acceptor< HANDLER >::set_handle ACE_HANDLE    handle [virtual]
 

Set the underlying listen handle. It is the user's responsibility to make sure that the old listen handle has been appropriately closed and the all outstanding asynchronous operations have either completed or have been canceled on the old listen handle.

Definition at line 138 of file Asynch_Acceptor.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, asynch_accept_, listen_handle_, LM_ERROR, and ACE_Asynch_Accept::open.

00139 {
00140   ACE_TRACE ("ACE_Asynch_Acceptor<>::set_handle");
00141 
00142   // Take ownership of the <listen_handle>
00143   this->listen_handle_ = listen_handle;
00144 
00145   // Reinitialize the ACE_Asynch_Accept
00146   if (this->asynch_accept_.open (*this,
00147                                  this->listen_handle_,
00148                                  0,
00149                                  this->proactor ()) == -1)
00150     ACE_ERROR ((LM_ERROR,
00151                 ACE_LIB_TEXT ("%p\n"),
00152                 ACE_LIB_TEXT ("ACE_Asynch_Accept::open")));
00153 }

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::should_reissue_accept void    [virtual]
 

Template method for deciding whether to reissue accept.

This hook method is called after each accept completes to decide if another accept should be initiated. If the method returns a non-zero value, another accept is initiated.

The default implemenation always returns the value passed as the open() method's reissue_accept argument. That value can also be changed using the reissue_accept() method.

Definition at line 455 of file Asynch_Acceptor.cpp.

References reissue_accept_.

Referenced by handle_accept.

00456 {
00457   return this->reissue_accept_;
00458 }

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::validate_connection const ACE_Asynch_Accept::Result   result,
const ACE_INET_Addr   remote,
const ACE_INET_Addr   local
[virtual]
 

Template method to validate peer before service is opened. This method is called after a new connection is accepted if the validate_connection argument to open() was non-zero or the validate_new_connection() method is called to turn this feature on. The default implementation returns 0. Users can reimplement this method to perform validation of the peer using it's address, running an authentication procedure (such as SSL) or anything else necessary or desireable. The return value from this method determines whether or not ACE will continue opening the service or abort the connection.

Parameters:
result  Result of the connection acceptance.
remote  Peer's address.
local  Local address connection was accepted at.
Return values:
-1  ACE_Asynch_Acceptor will close the connection, and the service will not be opened.
0  Service opening will proceeed.

Definition at line 290 of file Asynch_Acceptor.cpp.

Referenced by handle_accept.

00293 {
00294   // Default implementation always validates the remote address.
00295   return 0;
00296 }

template<class HANDLER>
void ACE_Asynch_Acceptor< HANDLER >::validate_new_connection int    new_value [virtual]
 

Set flag that indicates if address validation is required.

Definition at line 425 of file Asynch_Acceptor.cpp.

References validate_new_connection_.

00426 {
00427   this->validate_new_connection_ = new_value;
00428 }

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::validate_new_connection void    const [virtual]
 

Get flag that indicates if address validation is required.

Definition at line 419 of file Asynch_Acceptor.cpp.

References validate_new_connection_.

Referenced by handle_accept.

00420 {
00421   return this->validate_new_connection_;
00422 }

template<class HANDLER>
int ACE_Asynch_Acceptor< HANDLER >::validate_new_connection const ACE_INET_Addr   remote_address [virtual]
 

Deprecated:
Use validate_connection() instead. Will be removed after ACE 5.3.
Template method for address validation.

This hook method is called after a connection is accepted if so specified on the call to the open() method. If this method returns -1, the connection is immediately closed and the service handler is not opened.

The default implemenation always return 0.

Definition at line 299 of file Asynch_Acceptor.cpp.

Referenced by open.

00300 {
00301   // Default implementation always validates the remote address.
00302   return 0;
00303 }


Member Data Documentation

template<class HANDLER>
ACE_Asynch_Accept ACE_Asynch_Acceptor::asynch_accept_ [private]
 

<Asynch_Accept> used to make life easier :-).

Definition at line 260 of file Asynch_Acceptor.h.

Referenced by accept, asynch_accept, cancel, open, and set_handle.

template<class HANDLER>
size_t ACE_Asynch_Acceptor::bytes_to_read_ [private]
 

Bytes to be read with the <accept> call.

Definition at line 273 of file Asynch_Acceptor.h.

Referenced by bytes_to_read, and open.

template<class HANDLER>
ACE_HANDLE ACE_Asynch_Acceptor::listen_handle_ [private]
 

Handle used to listen for new connections.

Definition at line 257 of file Asynch_Acceptor.h.

Referenced by cancel, get_handle, handle, handle_accept, open, and set_handle.

template<class HANDLER>
int ACE_Asynch_Acceptor::pass_addresses_ [private]
 

Flag that indicates if parsing of addresses is necessary.

Definition at line 263 of file Asynch_Acceptor.h.

Referenced by handle_accept, open, and pass_addresses.

template<class HANDLER>
int ACE_Asynch_Acceptor::reissue_accept_ [private]
 

Flag that indicates if a new accept should be reissued when a accept completes.

Definition at line 270 of file Asynch_Acceptor.h.

Referenced by open, reissue_accept, and should_reissue_accept.

template<class HANDLER>
int ACE_Asynch_Acceptor::validate_new_connection_ [private]
 

Flag that indicates if address validation is required.

Definition at line 266 of file Asynch_Acceptor.h.

Referenced by handle_accept, open, and validate_new_connection.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:45:05 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002