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

ACE_Strategy_Acceptor 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:

Inheritance graph
[legend]
Collaboration diagram for ACE_Strategy_Acceptor:

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 Methods

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

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

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

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

virtual ACE_HANDLE get_handle (void) const
 Returns the listening acceptor's <ACE_HANDLE>. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

virtual int suspend (void)
 This method delegates to the <Scheduling_Strategy>'s <suspend> method. More...

virtual int resume (void)
 This method delegates to the <Scheduling_Strategy>'s <resume> method. More...

virtual int fini (void)
 Calls <handle_close> when dynamically unlinked. More...

virtual int info (ACE_TCHAR **buf, size_t) const
 Default version returns address info in <buf>. More...

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)
 Perform termination activities when <this> is removed from the <Reactor>. More...

virtual int handle_signal (int signum, siginfo_t *, ucontext_t *)
 Handle SIGINT. More...


Protected Attributes

CREATION_STRATEGYcreation_strategy_
 Creation strategy for an Acceptor. More...

int delete_creation_strategy_
 1 if <Acceptor> created the creation strategy and thus should delete it, else 0. More...

ACCEPT_STRATEGYaccept_strategy_
 Accept strategy for an <Acceptor>. More...

int delete_accept_strategy_
 1 if <Acceptor> created the accept strategy and thus should delete it, else 0. More...

CONCURRENCY_STRATEGYconcurrency_strategy_
 Concurrency strategy for an <Acceptor>. More...

int delete_concurrency_strategy_
 1 if <Acceptor> created the concurrency strategy and thus should delete it, else 0. More...

SCHEDULING_STRATEGYscheduling_strategy_
 Scheduling strategy for an <Acceptor>. More...

int delete_scheduling_strategy_
 1 if <Acceptor> created the scheduling strategy and thus should delete it, else 0. More...

ACE_TCHARservice_name_
 Name of the service. More...

ACE_TCHARservice_description_
 Description of the service. More...

ACE_PEER_ACCEPTOR_ADDR service_addr_
 Address that the <Strategy_Acceptor> uses to listen for connections. More...


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 246 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::ACCEPT_STRATEGY
 

Definition at line 264 of file Acceptor.h.

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

Definition at line 255 of file Acceptor.h.

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

Definition at line 260 of file Acceptor.h.

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

Definition at line 265 of file Acceptor.h.

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

Definition at line 257 of file Acceptor.h.

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

Definition at line 263 of file Acceptor.h.

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

Definition at line 253 of file Acceptor.h.

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

Definition at line 266 of file Acceptor.h.

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

Definition at line 258 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 611 of file Acceptor.cpp.

References ACE_ALLOCATOR, ACE_TCHAR, ACE_TRACE, and ACE_OS_String::strdup.

00615     : creation_strategy_ (0),
00616       delete_creation_strategy_ (0),
00617       accept_strategy_ (0),
00618       delete_accept_strategy_ (0),
00619       concurrency_strategy_ (0),
00620       delete_concurrency_strategy_ (0),
00621       scheduling_strategy_ (0),
00622       delete_scheduling_strategy_ (0),
00623       service_name_ (0),
00624       service_description_ (0)
00625 {
00626   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor");
00627 
00628   if (service_name != 0)
00629     ACE_ALLOCATOR (this->service_name_,
00630                    ACE_OS::strdup (service_name));
00631   if (service_description != 0)
00632     ACE_ALLOCATOR (this->service_description_,
00633                    ACE_OS::strdup (service_description));
00634   this->use_select_ = use_select;
00635   this->reuse_addr_ = reuse_addr;
00636 }

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 640 of file Acceptor.cpp.

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

00650     : creation_strategy_ (0),
00651       delete_creation_strategy_ (0),
00652       accept_strategy_ (0),
00653       delete_accept_strategy_ (0),
00654       concurrency_strategy_ (0),
00655       delete_concurrency_strategy_ (0),
00656       scheduling_strategy_ (0),
00657       delete_scheduling_strategy_ (0),
00658       service_name_ (0),
00659       service_description_ (0)
00660 {
00661   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor");
00662 
00663   if (this->open (addr,
00664                   reactor,
00665                   cre_s,
00666                   acc_s,
00667                   con_s,
00668                   sch_s,
00669                   service_name,
00670                   service_description,
00671                   use_select,
00672                   reuse_addr) == -1)
00673     ACE_ERROR ((LM_ERROR,
00674                 ACE_LIB_TEXT ("%p\n"),
00675                 ACE_LIB_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor")));
00676 }

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 771 of file Acceptor.cpp.

References ACE_TRACE, ACE_OS_Memory::free, and handle_close.

00772 {
00773   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Strategy_Acceptor");
00774   ACE_OS::free ((void *) this->service_name_);
00775   ACE_OS::free ((void *) this->service_description_);
00776   this->handle_close ();
00777 }


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 746 of file Acceptor.cpp.

References ACE_TRACE.

00747 {
00748   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
00749   return this->accept_strategy_->accept_svc_handler (svc_handler);
00750 }

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 472 of file Acceptor.cpp.

References accept_strategy_, ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::acceptor, and ACE_TRACE.

Referenced by info.

00473 {
00474   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
00475   return this->accept_strategy_->acceptor ();
00476 }

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 762 of file Acceptor.cpp.

References ACE_TRACE.

00763 {
00764   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
00765   return this->concurrency_strategy_->activate_svc_handler
00766     (svc_handler,
00767      (void *) this);
00768 }

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 449 of file Acceptor.cpp.

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

00450 {
00451   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
00452 
00453   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00454   ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump ();
00455   this->creation_strategy_->dump ();
00456   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("delete_creation_strategy_ = %d"), delete_creation_strategy_));
00457   this->accept_strategy_->dump ();
00458   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("delete_accept_strategy_ = %d"), delete_accept_strategy_));
00459   this->concurrency_strategy_->dump ();
00460   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("delete_concurrency_strategy_ = %d"), delete_concurrency_strategy_));
00461   this->scheduling_strategy_->dump ();
00462   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("delete_scheduling_strategy_ = %d"), delete_scheduling_strategy_));
00463   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nservice_name_ = %s"),
00464               this->service_name_ == 0 ? ACE_LIB_TEXT ("<unknown>") : this->service_name_));
00465   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nservice_description_ = %s"),
00466               this->service_description_ == 0 ? ACE_LIB_TEXT ("<unknown>") : this->service_description_));
00467   this->service_addr_.dump ();
00468   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00469 }

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 823 of file Acceptor.cpp.

References ACE_TRACE, and handle_close.

00824 {
00825   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini");
00826   return this->ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close ();
00827 }

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 488 of file Acceptor.cpp.

References accept_strategy_, ACE_TRACE, and ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::get_handle.

Referenced by handle_close.

00489 {
00490   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
00491   return this->accept_strategy_->get_handle ();
00492 }

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 682 of file Acceptor.cpp.

References ACE_Event_Handler::ACCEPT_MASK, accept_strategy_, ACE_Reactor_Mask, ACE_TRACE, concurrency_strategy_, creation_strategy_, delete_accept_strategy_, delete_concurrency_strategy_, delete_creation_strategy_, delete_scheduling_strategy_, ACE_Event_Handler::DONT_CALL, get_handle, ACE_Event_Handler::reactor, ACE_Reactor::remove_handler, and scheduling_strategy_.

Referenced by fini, and ~ACE_Strategy_Acceptor.

00684 {
00685   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close");
00686   // Guard against multiple closes.
00687   if (this->reactor () != 0)
00688     {
00689       ACE_HANDLE handle = this->get_handle ();
00690 
00691       if (this->delete_creation_strategy_)
00692         delete this->creation_strategy_;
00693       this->delete_creation_strategy_ = 0;
00694       this->creation_strategy_ = 0;
00695 
00696       if (this->delete_accept_strategy_)
00697         delete this->accept_strategy_;
00698       this->delete_accept_strategy_ = 0;
00699       this->accept_strategy_ = 0;
00700 
00701       if (this->delete_concurrency_strategy_)
00702         delete this->concurrency_strategy_;
00703       this->delete_concurrency_strategy_ = 0;
00704       this->concurrency_strategy_ = 0;
00705 
00706       if (this->delete_scheduling_strategy_)
00707         delete this->scheduling_strategy_;
00708       this->delete_scheduling_strategy_ = 0;
00709       this->scheduling_strategy_ = 0;
00710 
00711       // We must use the <handle> obtained *before* we deleted the
00712       // accept_strategy_...
00713 
00714       this->reactor ()->remove_handler
00715         (handle,
00716          ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
00717 
00718       // Set the Reactor to 0 so that we don't try to close down
00719       // again.
00720       this->reactor (0);
00721     }
00722   return 0;
00723 }

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 782 of file Acceptor.cpp.

References ACE_Reactor::end_event_loop, and ucontext_t.

00783 {
00784   ACE_Reactor::end_event_loop ();
00785   return 0;
00786 }

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 789 of file Acceptor.cpp.

References acceptor, ACE_LIB_TEXT, ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TRACE, service_description_, service_name_, ACE_OS::sprintf, ACE_OS_String::strdup, ACE_OS_String::strlen, and ACE_OS_String::strsncpy.

00791 {
00792   ACE_TRACE ("ACE_Strategy_Acceptor::info");
00793 
00794   ACE_TCHAR buf[BUFSIZ];
00795   ACE_TCHAR service_addr_str[BUFSIZ];
00796   ACE_PEER_ACCEPTOR_ADDR addr;
00797 
00798   if (this->acceptor ().get_local_addr (addr) == -1)
00799     return -1;
00800   else if (addr.addr_to_string (service_addr_str,
00801                                 sizeof service_addr_str) == -1)
00802     return -1;
00803 
00804   // @@ Should add the protocol in...
00805   ACE_OS::sprintf (buf,
00806                    ACE_LIB_TEXT ("%s\t %s #%s\n"),
00807                    this->service_name_ == 0
00808                    ? ACE_LIB_TEXT ("<unknown>")
00809                    : this->service_name_,
00810                    service_addr_str,
00811                    this->service_description_ == 0
00812                    ? ACE_LIB_TEXT ("<unknown>")
00813                    : this->service_description_);
00814 
00815   if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
00816     return -1;
00817   else
00818     ACE_OS::strsncpy (*strp, buf, length);
00819   return ACE_static_cast (int, ACE_OS::strlen (buf));
00820 }

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 734 of file Acceptor.cpp.

References ACE_TRACE, creation_strategy_, and ACE_Creation_Strategy::make_svc_handler.

00735 {
00736   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler");
00737   return this->creation_strategy_->make_svc_handler (sh);
00738 }

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 514 of file Acceptor.cpp.

References ACE_Event_Handler::ACCEPT_MASK, ACE_ALLOCATOR_RETURN, ACE_NEW_RETURN, ACE_NONBLOCK, ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TRACE, and ACE_OS_String::strdup.

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

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 500 of file Acceptor.cpp.

References ACE_PEER_ACCEPTOR_ADDR, and ACE_TRACE.

Referenced by ACE_Oneshot_Acceptor::open.

00505 {
00506   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
00507   return this->open
00508     (local_addr, reactor, 0, 0, 0, 0, 0, 0, use_select, reuse_addr);
00509 }

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 479 of file Acceptor.cpp.

References accept_strategy_, ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::acceptor, and ACE_TRACE.

00480 {
00481   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &");
00482   return this->accept_strategy_->acceptor ();
00483 }

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 437 of file Acceptor.cpp.

References ACE_TRACE, ACE_Scheduling_Strategy::resume, ACE_Acceptor::resume, and scheduling_strategy_.

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

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 425 of file Acceptor.cpp.

References ACE_TRACE, scheduling_strategy_, ACE_Acceptor::suspend, and ACE_Scheduling_Strategy::suspend.

00426 {
00427   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend");
00428 
00429   // First suspend the SVC_HANDLER's we've created.
00430   if (this->scheduling_strategy_->suspend () == -1)
00431     return -1;
00432   else   // Then suspend ourselves.
00433     return ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend ();
00434 }


Member Data Documentation

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

Accept strategy for an <Acceptor>.

Definition at line 442 of file Acceptor.h.

Referenced by acceptor, dump, get_handle, handle_close, and operator ACE_PEER_ACCEPTOR &.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 366 of file Acceptor.h.

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

Concurrency strategy for an <Acceptor>.

Definition at line 449 of file Acceptor.h.

Referenced by dump, and handle_close.

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

Creation strategy for an Acceptor.

Definition at line 435 of file Acceptor.h.

Referenced by dump, handle_close, and make_svc_handler.

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

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

Definition at line 446 of file Acceptor.h.

Referenced by dump, and handle_close.

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

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

Definition at line 453 of file Acceptor.h.

Referenced by dump, and handle_close.

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

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

Definition at line 439 of file Acceptor.h.

Referenced by dump, and handle_close.

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

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

Definition at line 460 of file Acceptor.h.

Referenced by dump, and handle_close.

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

Scheduling strategy for an <Acceptor>.

Definition at line 456 of file Acceptor.h.

Referenced by dump, handle_close, resume, and suspend.

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

Address that the <Strategy_Acceptor> uses to listen for connections.

Definition at line 472 of file Acceptor.h.

Referenced by dump.

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

Description of the service.

Definition at line 468 of file Acceptor.h.

Referenced by dump, and info.

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

Name of the service.

Definition at line 465 of file Acceptor.h.

Referenced by dump, and info.


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