#include <Acceptor.h>
Inheritance diagram for ACE_Strategy_Acceptor< SVC_HANDLER, >:
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. | |
virtual int | suspend (void) |
virtual int | resume (void) |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Member Functions | |
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_STRATEGY * | creation_strategy_ |
Creation strategy for an Acceptor. | |
bool | delete_creation_strategy_ |
ACCEPT_STRATEGY * | accept_strategy_ |
Accept strategy for an {Acceptor}. | |
bool | delete_accept_strategy_ |
CONCURRENCY_STRATEGY * | concurrency_strategy_ |
Concurrency strategy for an {Acceptor}. | |
bool | delete_concurrency_strategy_ |
SCHEDULING_STRATEGY * | scheduling_strategy_ |
Scheduling strategy for an {Acceptor}. | |
bool | delete_scheduling_strategy_ |
ACE_TCHAR * | service_name_ |
Name of the service. | |
ACE_TCHAR * | service_description_ |
Description of the service. | |
ACE_PEER_ACCEPTOR_ADDR | service_addr_ |
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 274 of file Acceptor.h.
typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::ACCEPT_STRATEGY |
Definition at line 292 of file Acceptor.h.
typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_type |
Definition at line 283 of file Acceptor.h.
typedef ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::base_type |
Definition at line 288 of file Acceptor.h.
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::CONCURRENCY_STRATEGY |
Definition at line 293 of file Acceptor.h.
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_type |
Definition at line 285 of file Acceptor.h.
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::CREATION_STRATEGY |
Definition at line 291 of file Acceptor.h.
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_type |
Definition at line 281 of file Acceptor.h.
typedef ACE_Scheduling_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::SCHEDULING_STRATEGY |
Definition at line 294 of file Acceptor.h.
typedef ACE_Scheduling_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_type |
Definition at line 286 of file Acceptor.h.
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 630 of file Acceptor.cpp.
References ACE_ALLOCATOR, ACE_TRACE, and ACE_OS::strdup().
00634 : creation_strategy_ (0), 00635 delete_creation_strategy_ (false), 00636 accept_strategy_ (0), 00637 delete_accept_strategy_ (false), 00638 concurrency_strategy_ (0), 00639 delete_concurrency_strategy_ (false), 00640 scheduling_strategy_ (0), 00641 delete_scheduling_strategy_ (false), 00642 service_name_ (0), 00643 service_description_ (0) 00644 { 00645 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor"); 00646 00647 if (service_name != 0) 00648 ACE_ALLOCATOR (this->service_name_, 00649 ACE_OS::strdup (service_name)); 00650 if (service_description != 0) 00651 ACE_ALLOCATOR (this->service_description_, 00652 ACE_OS::strdup (service_description)); 00653 this->use_select_ = use_select; 00654 this->reuse_addr_ = reuse_addr; 00655 }
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 659 of file Acceptor.cpp.
References ACE_ERROR, ACE_TEXT, ACE_TRACE, and LM_ERROR.
00669 : creation_strategy_ (0), 00670 delete_creation_strategy_ (false), 00671 accept_strategy_ (0), 00672 delete_accept_strategy_ (false), 00673 concurrency_strategy_ (0), 00674 delete_concurrency_strategy_ (false), 00675 scheduling_strategy_ (0), 00676 delete_scheduling_strategy_ (false), 00677 service_name_ (0), 00678 service_description_ (0) 00679 { 00680 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor"); 00681 00682 if (this->open (addr, 00683 reactor, 00684 cre_s, 00685 acc_s, 00686 con_s, 00687 sch_s, 00688 service_name, 00689 service_description, 00690 use_select, 00691 reuse_addr) == -1) 00692 ACE_ERROR ((LM_ERROR, 00693 ACE_TEXT ("%p\n"), 00694 ACE_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"))); 00695 }
ACE_Strategy_Acceptor< SVC_HANDLER, >::~ACE_Strategy_Acceptor | ( | void | ) | [virtual] |
Close down the Strategy_Acceptor's resources.
Definition at line 790 of file Acceptor.cpp.
References ACE_TRACE, ACE_OS::free(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().
00791 { 00792 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Strategy_Acceptor"); 00793 ACE_OS::free ((void *) this->service_name_); 00794 ACE_OS::free ((void *) this->service_description_); 00795 this->handle_close (); 00796 }
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 765 of file Acceptor.cpp.
References ACE_TRACE.
00766 { 00767 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler"); 00768 return this->accept_strategy_->accept_svc_handler (svc_handler); 00769 }
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 491 of file Acceptor.cpp.
References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_Accept_Strategy< SVC_HANDLER, >::acceptor(), and ACE_TRACE.
00492 { 00493 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor"); 00494 return this->accept_strategy_->acceptor (); 00495 }
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 781 of file Acceptor.cpp.
References ACE_TRACE.
00782 { 00783 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler"); 00784 return this->concurrency_strategy_->activate_svc_handler 00785 (svc_handler, 00786 (void *) this); 00787 }
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 466 of file Acceptor.cpp.
References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_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_.
00467 { 00468 #if defined (ACE_HAS_DUMP) 00469 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump"); 00470 00471 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00472 ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump (); 00473 this->creation_strategy_->dump (); 00474 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_creation_strategy_ = %d"), delete_creation_strategy_)); 00475 this->accept_strategy_->dump (); 00476 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_accept_strategy_ = %d"), delete_accept_strategy_)); 00477 this->concurrency_strategy_->dump (); 00478 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_concurrency_strategy_ = %d"), delete_concurrency_strategy_)); 00479 this->scheduling_strategy_->dump (); 00480 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_scheduling_strategy_ = %d"), delete_scheduling_strategy_)); 00481 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nservice_name_ = %s"), 00482 this->service_name_ == 0 ? ACE_TEXT ("<unknown>") : this->service_name_)); 00483 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nservice_description_ = %s"), 00484 this->service_description_ == 0 ? ACE_TEXT ("<unknown>") : this->service_description_)); 00485 this->service_addr_.dump (); 00486 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00487 #endif /* ACE_HAS_DUMP */ 00488 }
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 842 of file Acceptor.cpp.
References ACE_TRACE, and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().
00843 { 00844 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini"); 00845 return this->ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close (); 00846 }
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 507 of file Acceptor.cpp.
References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_TRACE, and ACE_Accept_Strategy< SVC_HANDLER, >::get_handle().
00508 { 00509 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle"); 00510 return this->accept_strategy_->get_handle (); 00511 }
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 701 of file Acceptor.cpp.
References ACE_Event_Handler::ACCEPT_MASK, ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, 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_Event_Handler::DONT_CALL, 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().
00703 { 00704 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close"); 00705 // Guard against multiple closes. 00706 if (this->reactor () != 0) 00707 { 00708 ACE_HANDLE handle = this->get_handle (); 00709 00710 if (this->delete_creation_strategy_) 00711 delete this->creation_strategy_; 00712 this->delete_creation_strategy_ = false; 00713 this->creation_strategy_ = 0; 00714 00715 if (this->delete_accept_strategy_) 00716 delete this->accept_strategy_; 00717 this->delete_accept_strategy_ = false; 00718 this->accept_strategy_ = 0; 00719 00720 if (this->delete_concurrency_strategy_) 00721 delete this->concurrency_strategy_; 00722 this->delete_concurrency_strategy_ = false; 00723 this->concurrency_strategy_ = 0; 00724 00725 if (this->delete_scheduling_strategy_) 00726 delete this->scheduling_strategy_; 00727 this->delete_scheduling_strategy_ = false; 00728 this->scheduling_strategy_ = 0; 00729 00730 // We must use the <handle> obtained *before* we deleted the 00731 // accept_strategy_... 00732 00733 this->reactor ()->remove_handler 00734 (handle, 00735 ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); 00736 00737 // Set the Reactor to 0 so that we don't try to close down 00738 // again. 00739 this->reactor (0); 00740 } 00741 return 0; 00742 }
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 801 of file Acceptor.cpp.
References ACE_Reactor::end_reactor_event_loop(), and ACE_Reactor::instance().
00802 { 00803 ACE_Reactor::instance()->end_reactor_event_loop (); 00804 return 0; 00805 }
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 808 of file Acceptor.cpp.
References ACE_PEER_ACCEPTOR_ADDR, ACE_TEXT, ACE_TRACE, ACE_OS::sprintf(), ACE_OS::strdup(), ACE_OS::strlen(), and ACE_OS::strsncpy().
00810 { 00811 ACE_TRACE ("ACE_Strategy_Acceptor::info"); 00812 00813 ACE_TCHAR buf[BUFSIZ]; 00814 ACE_TCHAR service_addr_str[BUFSIZ]; 00815 ACE_PEER_ACCEPTOR_ADDR addr; 00816 00817 if (this->acceptor ().get_local_addr (addr) == -1) 00818 return -1; 00819 else if (addr.addr_to_string (service_addr_str, 00820 sizeof service_addr_str) == -1) 00821 return -1; 00822 00823 // @@ Should add the protocol in... 00824 ACE_OS::sprintf (buf, 00825 ACE_TEXT ("%s\t %s #%s\n"), 00826 this->service_name_ == 0 00827 ? ACE_TEXT ("<unknown>") 00828 : this->service_name_, 00829 service_addr_str, 00830 this->service_description_ == 0 00831 ? ACE_TEXT ("<unknown>") 00832 : this->service_description_); 00833 00834 if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) 00835 return -1; 00836 else 00837 ACE_OS::strsncpy (*strp, buf, length); 00838 return static_cast<int> (ACE_OS::strlen (buf)); 00839 }
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 753 of file Acceptor.cpp.
References ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_, and ACE_Creation_Strategy< SVC_HANDLER >::make_svc_handler().
00754 { 00755 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler"); 00756 return this->creation_strategy_->make_svc_handler (sh); 00757 }
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 533 of file Acceptor.cpp.
References ACE_Event_Handler::ACCEPT_MASK, ACE_ALLOCATOR_RETURN, ACE_NEW_RETURN, ACE_NONBLOCK, ACE_TRACE, ACE_Reactor::register_handler(), and ACE_OS::strdup().
00543 { 00544 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open"); 00545 00546 if (this->service_name_ == 0 && service_name != 0) 00547 ACE_ALLOCATOR_RETURN (this->service_name_, 00548 ACE_OS::strdup (service_name), 00549 -1); 00550 if (this->service_description_ == 0 && service_description != 0) 00551 ACE_ALLOCATOR_RETURN (this->service_description_, 00552 ACE_OS::strdup (service_description), 00553 -1); 00554 this->reactor (reactor); 00555 00556 // Must supply a valid Reactor to Acceptor::open()... 00557 if (reactor == 0) 00558 { 00559 errno = EINVAL; 00560 return -1; 00561 } 00562 00563 // Initialize the creation strategy. 00564 00565 if (cre_s == 0) 00566 { 00567 ACE_NEW_RETURN (cre_s, 00568 CREATION_STRATEGY, 00569 -1); 00570 this->delete_creation_strategy_ = true; 00571 } 00572 this->creation_strategy_ = cre_s; 00573 00574 // Initialize the accept strategy. 00575 00576 if (acc_s == 0) 00577 { 00578 ACE_NEW_RETURN (acc_s, 00579 ACCEPT_STRATEGY (this->reactor ()), 00580 -1); 00581 this->delete_accept_strategy_ = true; 00582 } 00583 this->accept_strategy_ = acc_s; 00584 00585 if (this->accept_strategy_->open (local_addr, reuse_addr) == -1) 00586 return -1; 00587 00588 // Set the peer acceptor's handle into non-blocking mode. This is a 00589 // safe-guard against the race condition that can otherwise occur 00590 // between the time when <select> indicates that a passive-mode 00591 // socket handle is "ready" and when we call <accept>. During this 00592 // interval, the client can shutdown the connection, in which case, 00593 // the <accept> call can hang! 00594 if (this->accept_strategy_->acceptor ().enable (ACE_NONBLOCK) != 0) 00595 return -1; 00596 00597 // Initialize the concurrency strategy. 00598 00599 if (con_s == 0) 00600 { 00601 ACE_NEW_RETURN (con_s, 00602 CONCURRENCY_STRATEGY, 00603 -1); 00604 this->delete_concurrency_strategy_ = true; 00605 } 00606 this->concurrency_strategy_ = con_s; 00607 00608 // Initialize the scheduling strategy. 00609 00610 if (sch_s == 0) 00611 { 00612 ACE_NEW_RETURN (sch_s, 00613 SCHEDULING_STRATEGY, 00614 -1); 00615 this->delete_scheduling_strategy_ = true; 00616 } 00617 this->scheduling_strategy_ = sch_s; 00618 00619 this->use_select_ = use_select; 00620 00621 return this->reactor ()->register_handler 00622 (this, 00623 ACE_Event_Handler::ACCEPT_MASK); 00624 }
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.
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. |
0 | Success | |
-1 | Failure, errno contains an error code. |
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 519 of file Acceptor.cpp.
References ACE_TRACE, and ACE_OS::open().
00524 { 00525 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open"); 00526 return this->open 00527 (local_addr, reactor, 0, 0, 0, 0, 0, 0, use_select, reuse_addr); 00528 }
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 498 of file Acceptor.cpp.
References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_Accept_Strategy< SVC_HANDLER, >::acceptor(), and ACE_TRACE.
00499 { 00500 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &"); 00501 return this->accept_strategy_->acceptor (); 00502 }
int ACE_Strategy_Acceptor< SVC_HANDLER, >::resume | ( | void | ) | [virtual] |
This method delegates to the {Scheduling_Strategy}'s {resume} method.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 454 of file Acceptor.cpp.
References ACE_TRACE, ACE_Scheduling_Strategy< SVC_HANDLER >::resume(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_.
00455 { 00456 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume"); 00457 00458 // First resume ourselves. 00459 if (ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume () == -1) 00460 return -1; 00461 else // Then resume the SVC_HANDLER's we've created. 00462 return this->scheduling_strategy_->resume (); 00463 }
int ACE_Strategy_Acceptor< SVC_HANDLER, >::suspend | ( | void | ) | [virtual] |
This method delegates to the {Scheduling_Strategy}'s {suspend} method.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 442 of file Acceptor.cpp.
References ACE_TRACE, and ACE_Acceptor< SVC_HANDLER, >::suspend().
00443 { 00444 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend"); 00445 00446 // First suspend the SVC_HANDLER's we've created. 00447 if (this->scheduling_strategy_->suspend () == -1) 00448 return -1; 00449 else // Then suspend ourselves. 00450 return ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend (); 00451 }
ACCEPT_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_ [protected] |
Accept strategy for an {Acceptor}.
Definition at line 471 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 &().
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 394 of file Acceptor.h.
CONCURRENCY_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_ [protected] |
Concurrency strategy for an {Acceptor}.
Definition at line 478 of file Acceptor.h.
Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().
CREATION_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_ [protected] |
Creation strategy for an Acceptor.
Definition at line 464 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().
bool ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_accept_strategy_ [protected] |
true if {Acceptor} created the accept strategy and thus should delete it, else false.
Definition at line 475 of file Acceptor.h.
Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().
bool ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_concurrency_strategy_ [protected] |
true if {Acceptor} created the concurrency strategy and thus should delete it, else false.
Definition at line 482 of file Acceptor.h.
Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().
bool ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_creation_strategy_ [protected] |
true if {Acceptor} created the creation strategy and thus should delete it, else false.
Definition at line 468 of file Acceptor.h.
Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().
bool ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_scheduling_strategy_ [protected] |
true if {Acceptor} created the scheduling strategy and thus should delete it, else false.
Definition at line 489 of file Acceptor.h.
Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().
SCHEDULING_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_ [protected] |
Scheduling strategy for an {Acceptor}.
Definition at line 485 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, >::resume().
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 501 of file Acceptor.h.
Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump().
ACE_TCHAR* ACE_Strategy_Acceptor< SVC_HANDLER, >::service_description_ [protected] |
ACE_TCHAR* ACE_Strategy_Acceptor< SVC_HANDLER, >::service_name_ [protected] |