ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 > Class Template Reference

Defines the interface for specifying a passive connection acceptance strategy for a SVC_HANDLER. More...

#include <Strategies_T.h>

Collaboration diagram for ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef ACE_PEER_ACCEPTOR_ADDR addr_type
typedef ACE_PEER_ACCEPTOR acceptor_type
typedef SVC_HANDLER handler_type
typedef SVC_HANDLER::stream_type stream_type

Public Member Functions

 ACE_Accept_Strategy (ACE_Reactor *reactor=ACE_Reactor::instance())
 Default constructor.
 ACE_Accept_Strategy (const ACE_PEER_ACCEPTOR_ADDR &local_addr, bool restart=false, ACE_Reactor *reactor=ACE_Reactor::instance())
 Initialize the peer_acceptor_ with local_addr.
virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, bool reuse_addr=false)
virtual ACE_HANDLE get_handle (void) const
 Return the underlying ACE_HANDLE of the <peer_acceptor_>.
virtual ACE_PEER_ACCEPTOR & acceptor (void) const
 Return a reference to the <peer_acceptor_>.
virtual ~ACE_Accept_Strategy (void)
virtual int accept_svc_handler (SVC_HANDLER *)
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Protected Attributes

ACE_PEER_ACCEPTOR peer_acceptor_
 Factory that establishes connections passively.
ACE_Reactorreactor_
 Pointer to the reactor used by the Acceptor.
bool reuse_addr_
 Needed to reopen the socket if <accept> fails.
ACE_PEER_ACCEPTOR_ADDR peer_acceptor_addr_
 Needed to reopen the socket if <accept> fails.

Detailed Description

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
class ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >

Defines the interface for specifying a passive connection acceptance strategy for a SVC_HANDLER.

This class provides a strategy that manages passive connection acceptance of a client.

Definition at line 498 of file Strategies_T.h.


Member Typedef Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_PEER_ACCEPTOR ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::acceptor_type

Definition at line 504 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_PEER_ACCEPTOR_ADDR ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::addr_type

Definition at line 503 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef SVC_HANDLER ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::handler_type

Definition at line 505 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef SVC_HANDLER::stream_type ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::stream_type

Definition at line 506 of file Strategies_T.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_Accept_Strategy ( ACE_Reactor reactor = ACE_Reactor::instance ()  )  [inline]

Default constructor.

Definition at line 124 of file Strategies_T.inl.

00125   : reactor_ (reactor)
00126 {
00127   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy");
00128 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_Accept_Strategy ( const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
bool  restart = false,
ACE_Reactor reactor = ACE_Reactor::instance () 
) [inline]

Initialize the peer_acceptor_ with local_addr.

Definition at line 323 of file Strategies_T.cpp.

00326     : reactor_ (reactor)
00327 {
00328   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy");
00329 
00330   if (this->open (local_addr, reuse_addr) == -1)
00331     ACE_ERROR ((LM_ERROR,
00332                 ACE_TEXT ("%p\n"),
00333                 ACE_TEXT ("open")));
00334 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::~ACE_Accept_Strategy ( void   )  [inline, virtual]

Definition at line 1289 of file Strategies_T.cpp.

01290 {
01291   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy");
01292 
01293   // Close the underlying acceptor.
01294   this->peer_acceptor_.close ();
01295 }


Member Function Documentation

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::accept_svc_handler ( SVC_HANDLER *  svc_handler  )  [inline, virtual]

The default behavior delegates to the <accept> method of the PEER_ACCEPTOR.

Definition at line 338 of file Strategies_T.cpp.

00339 {
00340   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
00341 
00342   // Try to find out if the implementation of the reactor that we are
00343   // using requires us to reset the event association for the newly
00344   // created handle. This is because the newly created handle will
00345   // inherit the properties of the listen handle, including its event
00346   // associations.
00347   bool reset_new_handle = this->reactor_->uses_event_associations ();
00348 
00349   if (this->peer_acceptor_.accept (svc_handler->peer (), // stream
00350                                    0, // remote address
00351                                    0, // timeout
00352                                    1, // restart
00353                                    reset_new_handle  // reset new handler
00354                                    ) == -1)
00355     {
00356       // Ensure that errno is preserved in case the svc_handler
00357       // close() method resets it
00358       ACE_Errno_Guard error(errno);
00359 
00360       // Close down handler to avoid memory leaks.
00361       svc_handler->close (CLOSE_DURING_NEW_CONNECTION);
00362 
00363       return -1;
00364     }
00365   else
00366     return 0;
00367 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR & ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::acceptor ( void   )  const [inline, virtual]

Return a reference to the <peer_acceptor_>.

Definition at line 1305 of file Strategies_T.cpp.

01306 {
01307   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
01308   return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
01309 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
void ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::dump ( void   )  const [inline]

Dump the state of an object.

Definition at line 1312 of file Strategies_T.cpp.

01313 {
01314 #if defined (ACE_HAS_DUMP)
01315   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
01316 #endif /* ACE_HAS_DUMP */
01317 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
ACE_HANDLE ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::get_handle ( void   )  const [inline, virtual]

Return the underlying ACE_HANDLE of the <peer_acceptor_>.

Definition at line 1298 of file Strategies_T.cpp.

01299 {
01300   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
01301   return this->peer_acceptor_.get_handle ();
01302 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::open ( const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
bool  reuse_addr = false 
) [inline, virtual]

Initialize the <peer_acceptor_> with local_addr, indicating whether to reuse_addr if it's already in use.

Definition at line 304 of file Strategies_T.cpp.

00305 {
00306   this->reuse_addr_ = reuse_addr;
00307   this->peer_acceptor_addr_ = local_addr;
00308   if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1)
00309     return -1;
00310 
00311   // Set the peer acceptor's handle into non-blocking mode.  This is a
00312   // safe-guard against the race condition that can otherwise occur
00313   // between the time when <select> indicates that a passive-mode
00314   // socket handle is "ready" and when we call <accept>.  During this
00315   // interval, the client can shutdown the connection, in which case,
00316   // the <accept> call can hang!
00317   this->peer_acceptor_.enable (ACE_NONBLOCK);
00318   return 0;
00319 }


Member Data Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Definition at line 539 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::peer_acceptor_ [protected]

Factory that establishes connections passively.

Definition at line 543 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR_ADDR ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::peer_acceptor_addr_ [protected]

Needed to reopen the socket if <accept> fails.

Definition at line 552 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Reactor* ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::reactor_ [protected]

Pointer to the reactor used by the Acceptor.

Definition at line 546 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
bool ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::reuse_addr_ [protected]

Needed to reopen the socket if <accept> fails.

Definition at line 549 of file Strategies_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sun Nov 22 23:13:30 2009 for ACE by  doxygen 1.6.1