ACE_Accept_Strategy< SVC_HANDLER, > 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, >:

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, int restart=0, ACE_Reactor *reactor=ACE_Reactor::instance())
 Initialize the peer_acceptor_ with local_addr.
virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, int reuse_addr=0)
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.
int 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, >

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, >::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, >::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, >::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, >::stream_type

Definition at line 506 of file Strategies_T.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_INLINE ACE_Accept_Strategy< SVC_HANDLER, >::ACE_Accept_Strategy ( ACE_Reactor reactor = ACE_Reactor::instance()  ) 

Default constructor.

Definition at line 124 of file Strategies_T.inl.

References ACE_TRACE.

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_Accept_Strategy ( const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
int  restart = 0,
ACE_Reactor reactor = ACE_Reactor::instance() 
)

Initialize the peer_acceptor_ with local_addr.

Definition at line 319 of file Strategies_T.cpp.

References ACE_ERROR, ACE_TEXT, ACE_TRACE, and LM_ERROR.

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

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

Definition at line 1285 of file Strategies_T.cpp.

References ACE_TRACE, and ACE_Accept_Strategy< SVC_HANDLER, >::peer_acceptor_.

01286 {
01287   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy");
01288 
01289   // Close the underlying acceptor.
01290   this->peer_acceptor_.close ();
01291 }


Member Function Documentation

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

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

Definition at line 334 of file Strategies_T.cpp.

References ACE_TRACE.

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

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

Return a reference to the <peer_acceptor_>.

Definition at line 1301 of file Strategies_T.cpp.

References ACE_PEER_ACCEPTOR, ACE_TRACE, and ACE_Accept_Strategy< SVC_HANDLER, >::peer_acceptor_.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::acceptor(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::operator ACE_PEER_ACCEPTOR &().

01302 {
01303   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
01304   return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
01305 }

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

Dump the state of an object.

Definition at line 1308 of file Strategies_T.cpp.

References ACE_TRACE.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump().

01309 {
01310 #if defined (ACE_HAS_DUMP)
01311   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
01312 #endif /* ACE_HAS_DUMP */
01313 }

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

Return the underlying ACE_HANDLE of the <peer_acceptor_>.

Definition at line 1294 of file Strategies_T.cpp.

References ACE_TRACE, and ACE_Accept_Strategy< SVC_HANDLER, >::peer_acceptor_.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::get_handle().

01295 {
01296   ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
01297   return this->peer_acceptor_.get_handle ();
01298 }

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

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

Definition at line 299 of file Strategies_T.cpp.

References ACE_NONBLOCK.

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


Member Data Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Accept_Strategy< SVC_HANDLER, >::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, >::peer_acceptor_ [protected]

Factory that establishes connections passively.

Definition at line 543 of file Strategies_T.h.

Referenced by ACE_Accept_Strategy< SVC_HANDLER, >::acceptor(), ACE_Accept_Strategy< SVC_HANDLER, >::get_handle(), and ACE_Accept_Strategy< SVC_HANDLER, >::~ACE_Accept_Strategy().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR_ADDR ACE_Accept_Strategy< SVC_HANDLER, >::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, >::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 >
int ACE_Accept_Strategy< SVC_HANDLER, >::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:
Generated on Tue Feb 2 17:34:52 2010 for ACE by  doxygen 1.4.7