ACE_Strategy_Acceptor< SVC_HANDLER, > Class Template Reference

Abstract factory for creating a service handler (SVC_HANDLER), accepting into the SVC_HANDLER, and activating the SVC_HANDLER. More...

#include <Acceptor.h>

Inheritance diagram for ACE_Strategy_Acceptor< SVC_HANDLER, >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Strategy_Acceptor< SVC_HANDLER, >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Creation_Strategy<
SVC_HANDLER > 
creation_strategy_type
typedef ACE_Accept_Strategy<
SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > 
accept_strategy_type
typedef ACE_Concurrency_Strategy<
SVC_HANDLER > 
concurrency_strategy_type
typedef ACE_Scheduling_Strategy<
SVC_HANDLER > 
scheduling_strategy_type
typedef ACE_Acceptor< SVC_HANDLER,
ACE_PEER_ACCEPTOR_2 > 
base_type
typedef ACE_Creation_Strategy<
SVC_HANDLER > 
CREATION_STRATEGY
typedef ACE_Accept_Strategy<
SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > 
ACCEPT_STRATEGY
typedef ACE_Concurrency_Strategy<
SVC_HANDLER > 
CONCURRENCY_STRATEGY
typedef ACE_Scheduling_Strategy<
SVC_HANDLER > 
SCHEDULING_STRATEGY

Public Member Functions

 ACE_Strategy_Acceptor (const ACE_TCHAR service_name[]=0, const ACE_TCHAR service_description[]=0, int use_select=1, int reuse_addr=1)
 Default constructor.

 ACE_Strategy_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, ACE_Reactor *=ACE_Reactor::instance(), ACE_Creation_Strategy< SVC_HANDLER > *=0, ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > *=0, ACE_Concurrency_Strategy< SVC_HANDLER > *=0, ACE_Scheduling_Strategy< SVC_HANDLER > *=0, const ACE_TCHAR service_name[]=0, const ACE_TCHAR service_description[]=0, int use_select=1, int reuse_addr=1)
virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, ACE_Reactor *reactor, int flags=0, int use_select=1, int reuse_addr=1)
virtual int open (const ACE_PEER_ACCEPTOR_ADDR &, ACE_Reactor *=ACE_Reactor::instance(), ACE_Creation_Strategy< SVC_HANDLER > *=0, ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > *=0, ACE_Concurrency_Strategy< SVC_HANDLER > *=0, ACE_Scheduling_Strategy< SVC_HANDLER > *=0, const ACE_TCHAR *service_name=0, const ACE_TCHAR *service_description=0, int use_select=1, int reuse_addr=1)
virtual ~ACE_Strategy_Acceptor (void)
 Close down the Strategy_Acceptor's resources.

virtual operator ACE_PEER_ACCEPTOR & () const
 Return the underlying PEER_ACCEPTOR object.

virtual ACE_PEER_ACCEPTOR & acceptor (void) const
 Return the underlying PEER_ACCEPTOR object.

virtual ACE_HANDLE get_handle (void) const
 Returns the listening acceptor's {ACE_HANDLE}.

void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Member Functions

virtual int suspend (void)
virtual int resume (void)
virtual int fini (void)
 Calls {handle_close} when dynamically unlinked.

virtual int info (ACE_TCHAR **buf, size_t) const
 Default version returns address info in {buf}.

virtual int make_svc_handler (SVC_HANDLER *&)
virtual int accept_svc_handler (SVC_HANDLER *svc_handler)
virtual int activate_svc_handler (SVC_HANDLER *svc_handler)
virtual int handle_close (ACE_HANDLE=ACE_INVALID_HANDLE, ACE_Reactor_Mask=ACE_Event_Handler::ALL_EVENTS_MASK)
virtual int handle_signal (int signum, siginfo_t *, ucontext_t *)
 Handle SIGINT.


Protected Attributes

CREATION_STRATEGYcreation_strategy_
 Creation strategy for an Acceptor.

int delete_creation_strategy_
ACCEPT_STRATEGYaccept_strategy_
 Accept strategy for an {Acceptor}.

int delete_accept_strategy_
CONCURRENCY_STRATEGYconcurrency_strategy_
 Concurrency strategy for an {Acceptor}.

int delete_concurrency_strategy_
SCHEDULING_STRATEGYscheduling_strategy_
 Scheduling strategy for an {Acceptor}.

int delete_scheduling_strategy_
ACE_TCHARservice_name_
 Name of the service.

ACE_TCHARservice_description_
 Description of the service.

ACE_PEER_ACCEPTOR_ADDR service_addr_

Detailed Description

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
class ACE_Strategy_Acceptor< SVC_HANDLER, >

Abstract factory for creating a service handler (SVC_HANDLER), accepting into the SVC_HANDLER, and activating the SVC_HANDLER.

Implements a flexible and extensible set of strategies for passively establishing connections with clients. There are three main strategies: (1) creating a SVC_HANDLER, (2) passively accepting a new connection from a client into the SVC_HANDLER, and (3) activating the SVC_HANDLER with a particular concurrency mechanism.

Definition at line 270 of file Acceptor.h.


Member Typedef Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::ACCEPT_STRATEGY
 

Definition at line 288 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_type
 

Definition at line 279 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::base_type
 

Definition at line 284 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::CONCURRENCY_STRATEGY
 

Definition at line 289 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_type
 

Definition at line 281 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::CREATION_STRATEGY
 

Definition at line 287 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_type
 

Definition at line 277 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Scheduling_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::SCHEDULING_STRATEGY
 

Definition at line 290 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Scheduling_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_type
 

Definition at line 282 of file Acceptor.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor< SVC_HANDLER, >::ACE_Strategy_Acceptor const ACE_TCHAR  service_name[] = 0,
const ACE_TCHAR  service_description[] = 0,
int  use_select = 1,
int  reuse_addr = 1
 

Default constructor.

Definition at line 625 of file Acceptor.cpp.

References ACE_ALLOCATOR, ACE_TCHAR, and ACE_TRACE.

00629     : creation_strategy_ (0),
00630       delete_creation_strategy_ (0),
00631       accept_strategy_ (0),
00632       delete_accept_strategy_ (0),
00633       concurrency_strategy_ (0),
00634       delete_concurrency_strategy_ (0),
00635       scheduling_strategy_ (0),
00636       delete_scheduling_strategy_ (0),
00637       service_name_ (0),
00638       service_description_ (0)
00639 {
00640   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor");
00641 
00642   if (service_name != 0)
00643     ACE_ALLOCATOR (this->service_name_,
00644                    ACE_OS::strdup (service_name));
00645   if (service_description != 0)
00646     ACE_ALLOCATOR (this->service_description_,
00647                    ACE_OS::strdup (service_description));
00648   this->use_select_ = use_select;
00649   this->reuse_addr_ = reuse_addr;
00650 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor< SVC_HANDLER, >::ACE_Strategy_Acceptor const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
ACE_Reactor = ACE_Reactor::instance(),
ACE_Creation_Strategy< SVC_HANDLER > *  = 0,
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > *  = 0,
ACE_Concurrency_Strategy< SVC_HANDLER > *  = 0,
ACE_Scheduling_Strategy< SVC_HANDLER > *  = 0,
const ACE_TCHAR  service_name[] = 0,
const ACE_TCHAR  service_description[] = 0,
int  use_select = 1,
int  reuse_addr = 1
 

Initialize the appropriate strategies for creation, passive connection acceptance, and concurrency, and then register {this} with the Reactor and listen for connection requests at the designated {local_addr}.

Definition at line 654 of file Acceptor.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TRACE, and LM_ERROR.

00664     : creation_strategy_ (0),
00665       delete_creation_strategy_ (0),
00666       accept_strategy_ (0),
00667       delete_accept_strategy_ (0),
00668       concurrency_strategy_ (0),
00669       delete_concurrency_strategy_ (0),
00670       scheduling_strategy_ (0),
00671       delete_scheduling_strategy_ (0),
00672       service_name_ (0),
00673       service_description_ (0)
00674 {
00675   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor");
00676 
00677   if (this->open (addr,
00678                   reactor,
00679                   cre_s,
00680                   acc_s,
00681                   con_s,
00682                   sch_s,
00683                   service_name,
00684                   service_description,
00685                   use_select,
00686                   reuse_addr) == -1)
00687     ACE_ERROR ((LM_ERROR,
00688                 ACE_LIB_TEXT ("%p\n"),
00689                 ACE_LIB_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor")));
00690 }

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

Close down the Strategy_Acceptor's resources.

Definition at line 785 of file Acceptor.cpp.

References ACE_TRACE, ACE_OS::free(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

00786 {
00787   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Strategy_Acceptor");
00788   ACE_OS::free ((void *) this->service_name_);
00789   ACE_OS::free ((void *) this->service_description_);
00790   this->handle_close ();
00791 }


Member Function Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_svc_handler SVC_HANDLER *  svc_handler  )  [protected, virtual]
 

Bridge method for accepting the new connection into the {SVC_HANDLER}. The default behavior delegates to the {PEER_ACCEPTOR::accept} in the {Acceptor_Strategy}.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 760 of file Acceptor.cpp.

References ACE_TRACE.

00761 {
00762   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
00763   return this->accept_strategy_->accept_svc_handler (svc_handler);
00764 }

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

Return the underlying PEER_ACCEPTOR object.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 486 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_Accept_Strategy< SVC_HANDLER, >::acceptor(), and ACE_TRACE.

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

00487 {
00488   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
00489   return this->accept_strategy_->acceptor ();
00490 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::activate_svc_handler SVC_HANDLER *  svc_handler  )  [protected, virtual]
 

Bridge method for activating a {SVC_HANDLER} with the appropriate concurrency strategy. The default behavior of this method is to activate the {SVC_HANDLER} by calling its {open} method (which allows the {SVC_HANDLER} to define its own concurrency strategy). However, subclasses can override this strategy to do more sophisticated concurrency activations (such as creating the {SVC_HANDLER} as an "active object" via multi-threading or multi-processing).

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 776 of file Acceptor.cpp.

References ACE_TRACE.

00777 {
00778   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
00779   return this->concurrency_strategy_->activate_svc_handler
00780     (svc_handler,
00781      (void *) this);
00782 }

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

Dump the state of an object.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 461 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_accept_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_concurrency_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_creation_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_scheduling_strategy_, ACE_Scheduling_Strategy< SVC_HANDLER >::dump(), ACE_Concurrency_Strategy< SVC_HANDLER >::dump(), ACE_Accept_Strategy< SVC_HANDLER, >::dump(), ACE_Creation_Strategy< SVC_HANDLER >::dump(), ACE_Acceptor< SVC_HANDLER, >::dump(), LM_DEBUG, ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_, and ACE_Strategy_Acceptor< SVC_HANDLER, >::service_addr_.

00462 {
00463 #if defined (ACE_HAS_DUMP)
00464   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
00465 
00466   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00467   ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump ();
00468   this->creation_strategy_->dump ();
00469   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("delete_creation_strategy_ = %d"), delete_creation_strategy_));
00470   this->accept_strategy_->dump ();
00471   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("delete_accept_strategy_ = %d"), delete_accept_strategy_));
00472   this->concurrency_strategy_->dump ();
00473   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("delete_concurrency_strategy_ = %d"), delete_concurrency_strategy_));
00474   this->scheduling_strategy_->dump ();
00475   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("delete_scheduling_strategy_ = %d"), delete_scheduling_strategy_));
00476   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nservice_name_ = %s"),
00477               this->service_name_ == 0 ? ACE_LIB_TEXT ("<unknown>") : this->service_name_));
00478   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nservice_description_ = %s"),
00479               this->service_description_ == 0 ? ACE_LIB_TEXT ("<unknown>") : this->service_description_));
00480   this->service_addr_.dump ();
00481   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00482 #endif /* ACE_HAS_DUMP */
00483 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::fini void   )  [protected, virtual]
 

Calls {handle_close} when dynamically unlinked.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 837 of file Acceptor.cpp.

References ACE_TRACE, and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

00838 {
00839   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini");
00840   return this->ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close ();
00841 }

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

Returns the listening acceptor's {ACE_HANDLE}.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 502 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_TRACE, and ACE_Accept_Strategy< SVC_HANDLER, >::get_handle().

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

00503 {
00504   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
00505   return this->accept_strategy_->get_handle ();
00506 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close ACE_HANDLE  = ACE_INVALID_HANDLE,
ACE_Reactor_Mask  = ACE_Event_Handler::ALL_EVENTS_MASK
[protected, virtual]
 

Perform termination activities when {this} is removed from the {Reactor}.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 696 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_Reactor_Mask, ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_accept_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_concurrency_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_creation_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_scheduling_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::get_handle(), ACE_Event_Handler::reactor(), ACE_Reactor::remove_handler(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::fini(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::~ACE_Strategy_Acceptor().

00698 {
00699   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close");
00700   // Guard against multiple closes.
00701   if (this->reactor () != 0)
00702     {
00703       ACE_HANDLE handle = this->get_handle ();
00704 
00705       if (this->delete_creation_strategy_)
00706         delete this->creation_strategy_;
00707       this->delete_creation_strategy_ = 0;
00708       this->creation_strategy_ = 0;
00709 
00710       if (this->delete_accept_strategy_)
00711         delete this->accept_strategy_;
00712       this->delete_accept_strategy_ = 0;
00713       this->accept_strategy_ = 0;
00714 
00715       if (this->delete_concurrency_strategy_)
00716         delete this->concurrency_strategy_;
00717       this->delete_concurrency_strategy_ = 0;
00718       this->concurrency_strategy_ = 0;
00719 
00720       if (this->delete_scheduling_strategy_)
00721         delete this->scheduling_strategy_;
00722       this->delete_scheduling_strategy_ = 0;
00723       this->scheduling_strategy_ = 0;
00724 
00725       // We must use the <handle> obtained *before* we deleted the
00726       // accept_strategy_...
00727 
00728       this->reactor ()->remove_handler
00729         (handle,
00730          ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
00731 
00732       // Set the Reactor to 0 so that we don't try to close down
00733       // again.
00734       this->reactor (0);
00735     }
00736   return 0;
00737 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_signal int  signum,
siginfo_t ,
ucontext_t
[protected, virtual]
 

Handle SIGINT.

Reimplemented from ACE_Event_Handler.

Definition at line 796 of file Acceptor.cpp.

References ACE_Reactor::end_reactor_event_loop(), ACE_Reactor::instance(), and ucontext_t.

00797 {
00798   ACE_Reactor::instance()->end_reactor_event_loop ();
00799   return 0;
00800 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::info ACE_TCHAR **  buf,
size_t 
const [protected, virtual]
 

Default version returns address info in {buf}.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 803 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::acceptor(), ACE_LIB_TEXT, ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TRACE, ACE_OS::sprintf(), ACE_OS::strdup(), ACE_OS::strlen(), and ACE_OS::strsncpy().

00805 {
00806   ACE_TRACE ("ACE_Strategy_Acceptor::info");
00807 
00808   ACE_TCHAR buf[BUFSIZ];
00809   ACE_TCHAR service_addr_str[BUFSIZ];
00810   ACE_PEER_ACCEPTOR_ADDR addr;
00811 
00812   if (this->acceptor ().get_local_addr (addr) == -1)
00813     return -1;
00814   else if (addr.addr_to_string (service_addr_str,
00815                                 sizeof service_addr_str) == -1)
00816     return -1;
00817 
00818   // @@ Should add the protocol in...
00819   ACE_OS::sprintf (buf,
00820                    ACE_LIB_TEXT ("%s\t %s #%s\n"),
00821                    this->service_name_ == 0
00822                    ? ACE_LIB_TEXT ("<unknown>")
00823                    : this->service_name_,
00824                    service_addr_str,
00825                    this->service_description_ == 0
00826                    ? ACE_LIB_TEXT ("<unknown>")
00827                    : this->service_description_);
00828 
00829   if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
00830     return -1;
00831   else
00832     ACE_OS::strsncpy (*strp, buf, length);
00833   return static_cast<int> (ACE_OS::strlen (buf));
00834 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::make_svc_handler SVC_HANDLER *&   )  [protected, virtual]
 

Bridge method for creating a {SVC_HANDLER}. The strategy for creating a {SVC_HANDLER} are configured into the Acceptor via it's {creation_strategy_}. The default is to create a new {SVC_HANDLER} if {sh} == 0, else {sh} is unchanged. However, subclasses can override this policy to perform {SVC_HANDLER} creation in any way that they like (such as creating subclass instances of {SVC_HANDLER}, using a singleton, dynamically linking the handler, etc.). Returns -1 on failure, else 0.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 748 of file Acceptor.cpp.

References ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_, and ACE_Creation_Strategy< SVC_HANDLER >::make_svc_handler().

00749 {
00750   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler");
00751   return this->creation_strategy_->make_svc_handler (sh);
00752 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::open const ACE_PEER_ACCEPTOR_ADDR &  ,
ACE_Reactor = ACE_Reactor::instance(),
ACE_Creation_Strategy< SVC_HANDLER > *  = 0,
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > *  = 0,
ACE_Concurrency_Strategy< SVC_HANDLER > *  = 0,
ACE_Scheduling_Strategy< SVC_HANDLER > *  = 0,
const ACE_TCHAR service_name = 0,
const ACE_TCHAR service_description = 0,
int  use_select = 1,
int  reuse_addr = 1
[virtual]
 

Initialize the appropriate strategies for creation, passive connection acceptance, and concurrency, and then register {this} with the Reactor and listen for connection requests at the designated {local_addr}.

Definition at line 528 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::ACCEPT_STRATEGY, ACE_ALLOCATOR_RETURN, ACE_NEW_RETURN, ACE_NONBLOCK, ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::CONCURRENCY_STRATEGY, ACE_Strategy_Acceptor< SVC_HANDLER, >::CREATION_STRATEGY, and ACE_Strategy_Acceptor< SVC_HANDLER, >::SCHEDULING_STRATEGY.

00538 {
00539   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
00540 
00541   if (this->service_name_ == 0 && service_name != 0)
00542     ACE_ALLOCATOR_RETURN (this->service_name_,
00543                           ACE_OS::strdup (service_name),
00544                           -1);
00545   if (this->service_description_ == 0 && service_description != 0)
00546     ACE_ALLOCATOR_RETURN (this->service_description_,
00547                           ACE_OS::strdup (service_description),
00548                           -1);
00549   this->reactor (reactor);
00550 
00551   // Must supply a valid Reactor to Acceptor::open()...
00552   if (reactor == 0)
00553     {
00554       errno = EINVAL;
00555       return -1;
00556     }
00557 
00558   // Initialize the creation strategy.
00559 
00560   if (cre_s == 0)
00561     {
00562       ACE_NEW_RETURN (cre_s,
00563                       CREATION_STRATEGY,
00564                       -1);
00565       this->delete_creation_strategy_ = 1;
00566     }
00567   this->creation_strategy_ = cre_s;
00568 
00569   // Initialize the accept strategy.
00570 
00571   if (acc_s == 0)
00572     {
00573       ACE_NEW_RETURN (acc_s,
00574                       ACCEPT_STRATEGY (this->reactor ()),
00575                       -1);
00576       this->delete_accept_strategy_ = 1;
00577     }
00578   this->accept_strategy_ = acc_s;
00579 
00580   if (this->accept_strategy_->open (local_addr, reuse_addr) == -1)
00581     return -1;
00582 
00583   // Set the peer acceptor's handle into non-blocking mode.  This is a
00584   // safe-guard against the race condition that can otherwise occur
00585   // between the time when <select> indicates that a passive-mode
00586   // socket handle is "ready" and when we call <accept>.  During this
00587   // interval, the client can shutdown the connection, in which case,
00588   // the <accept> call can hang!
00589   if (this->accept_strategy_->acceptor ().enable (ACE_NONBLOCK) != 0)
00590     return -1;
00591 
00592   // Initialize the concurrency strategy.
00593 
00594   if (con_s == 0)
00595     {
00596       ACE_NEW_RETURN (con_s,
00597                       CONCURRENCY_STRATEGY,
00598                       -1);
00599       this->delete_concurrency_strategy_ = 1;
00600     }
00601   this->concurrency_strategy_ = con_s;
00602 
00603   // Initialize the scheduling strategy.
00604 
00605   if (sch_s == 0)
00606     {
00607       ACE_NEW_RETURN (sch_s,
00608                       SCHEDULING_STRATEGY,
00609                       -1);
00610       this->delete_scheduling_strategy_ = 1;
00611     }
00612   this->scheduling_strategy_ = sch_s;
00613 
00614   this->use_select_ = use_select;
00615 
00616   return this->reactor ()->register_handler
00617     (this,
00618      ACE_Event_Handler::ACCEPT_MASK);
00619 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::open const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
ACE_Reactor reactor,
int  flags = 0,
int  use_select = 1,
int  reuse_addr = 1
[virtual]
 

Open the contained PEER_ACCEPTOR object to begin listening, and register with the specified reactor for accept events.

The PEER_ACCEPTOR handle is put into non-blocking mode as a safeguard against the race condition that can otherwise occur between the time when the passive-mode socket handle is "ready" and when the actual accept call is made. During this interval, the client can shutdown the connection, in which case, the {accept} call can hang.

Parameters:
local_addr The address to listen at.
reactor Pointer to the ACE_Reactor instance to register this object with. The default is the singleton.
flags Flags to control what mode an accepted socket will be put into after it is accepted. The only legal value for this argument is ACE_NONBLOCK, which enables non-blocking mode on the accepted peer stream object in SVC_HANDLER. The default is 0.
use_select Affects behavior when called back by the reactor when a connection can be accepted. If non-zero, this object will accept all pending connections, intead of just the one that triggered the reactor callback. Uses ACE_OS::select() internally to detect any remaining acceptable connections. The default is 1.
reuse_addr Passed to the PEER_ACCEPTOR::open() method with local_addr. Generally used to request that the OS allow reuse of the listen port. The default is 1.
Return values:
0 Success
-1 Failure, errno contains an error code.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 514 of file Acceptor.cpp.

References ACE_PEER_ACCEPTOR_ADDR, and ACE_TRACE.

Referenced by ACE_Oneshot_Acceptor< SVC_HANDLER, >::open().

00519 {
00520   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
00521   return this->open
00522     (local_addr, reactor, 0, 0, 0, 0, 0, 0, use_select, reuse_addr);
00523 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor< SVC_HANDLER, >::operator ACE_PEER_ACCEPTOR &  )  const [virtual]
 

Return the underlying PEER_ACCEPTOR object.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 493 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_Accept_Strategy< SVC_HANDLER, >::acceptor(), and ACE_TRACE.

00494 {
00495   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &");
00496   return this->accept_strategy_->acceptor ();
00497 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::resume void   )  [protected, virtual]
 

This method delegates to the {Scheduling_Strategy}'s {resume} method.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 449 of file Acceptor.cpp.

References ACE_TRACE, ACE_Scheduling_Strategy< SVC_HANDLER >::resume(), ACE_Acceptor< SVC_HANDLER, >::resume(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_.

00450 {
00451   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume");
00452 
00453   // First resume ourselves.
00454   if (ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume () == -1)
00455     return -1;
00456   else // Then resume the SVC_HANDLER's we've created.
00457     return this->scheduling_strategy_->resume ();
00458 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::suspend void   )  [protected, virtual]
 

This method delegates to the {Scheduling_Strategy}'s {suspend} method.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 437 of file Acceptor.cpp.

References ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_, ACE_Acceptor< SVC_HANDLER, >::suspend(), and ACE_Scheduling_Strategy< SVC_HANDLER >::suspend().

00438 {
00439   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend");
00440 
00441   // First suspend the SVC_HANDLER's we've created.
00442   if (this->scheduling_strategy_->suspend () == -1)
00443     return -1;
00444   else   // Then suspend ourselves.
00445     return ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend ();
00446 }


Member Data Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACCEPT_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_ [protected]
 

Accept strategy for an {Acceptor}.

Definition at line 466 of file Acceptor.h.

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

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

Declare the dynamic allocation hooks.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 390 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
CONCURRENCY_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_ [protected]
 

Concurrency strategy for an {Acceptor}.

Definition at line 473 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
CREATION_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_ [protected]
 

Creation strategy for an Acceptor.

Definition at line 459 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_accept_strategy_ [protected]
 

1 if {Acceptor} created the accept strategy and thus should delete it, else 0.

Definition at line 470 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_concurrency_strategy_ [protected]
 

1 if {Acceptor} created the concurrency strategy and thus should delete it, else 0.

Definition at line 477 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_creation_strategy_ [protected]
 

1 if {Acceptor} created the creation strategy and thus should delete it, else 0.

Definition at line 463 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_scheduling_strategy_ [protected]
 

1 if {Acceptor} created the scheduling strategy and thus should delete it, else 0.

Definition at line 484 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
SCHEDULING_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_ [protected]
 

Scheduling strategy for an {Acceptor}.

Definition at line 480 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close(), ACE_Strategy_Acceptor< SVC_HANDLER, >::resume(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::suspend().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR_ADDR ACE_Strategy_Acceptor< SVC_HANDLER, >::service_addr_ [protected]
 

Address that the {Strategy_Acceptor} uses to listen for connections.

Definition at line 496 of file Acceptor.h.

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

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_TCHAR* ACE_Strategy_Acceptor< SVC_HANDLER, >::service_description_ [protected]
 

Description of the service.

Definition at line 492 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_TCHAR* ACE_Strategy_Acceptor< SVC_HANDLER, >::service_name_ [protected]
 

Name of the service.

Definition at line 489 of file Acceptor.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:30:14 2006 for ACE by doxygen 1.3.6