Abstract factory for creating a service handler (SVC_HANDLER), accepting into the SVC_HANDLER, and activating the SVC_HANDLER. More...
#include <Acceptor.h>


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_ |
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 274 of file Acceptor.h.
| typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::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, ACE_PEER_ACCEPTOR_1 >::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, ACE_PEER_ACCEPTOR_1 >::base_type |
Definition at line 288 of file Acceptor.h.
| typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::CONCURRENCY_STRATEGY |
Definition at line 293 of file Acceptor.h.
| typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::concurrency_strategy_type |
Definition at line 285 of file Acceptor.h.
| typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::CREATION_STRATEGY |
Definition at line 291 of file Acceptor.h.
| typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::creation_strategy_type |
Definition at line 281 of file Acceptor.h.
| typedef ACE_Scheduling_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::SCHEDULING_STRATEGY |
Definition at line 294 of file Acceptor.h.
| typedef ACE_Scheduling_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::scheduling_strategy_type |
Definition at line 286 of file Acceptor.h.
| ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_Strategy_Acceptor | ( | const ACE_TCHAR | service_name[] = 0, |
|
| const ACE_TCHAR | service_description[] = 0, |
|||
| int | use_select = 1, |
|||
| int | reuse_addr = 1 | |||
| ) | [inline] |
Default constructor.
Definition at line 643 of file Acceptor.cpp.
00647 : creation_strategy_ (0), 00648 delete_creation_strategy_ (false), 00649 accept_strategy_ (0), 00650 delete_accept_strategy_ (false), 00651 concurrency_strategy_ (0), 00652 delete_concurrency_strategy_ (false), 00653 scheduling_strategy_ (0), 00654 delete_scheduling_strategy_ (false), 00655 service_name_ (0), 00656 service_description_ (0) 00657 { 00658 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor"); 00659 00660 if (service_name != 0) 00661 ACE_ALLOCATOR (this->service_name_, 00662 ACE_OS::strdup (service_name)); 00663 if (service_description != 0) 00664 ACE_ALLOCATOR (this->service_description_, 00665 ACE_OS::strdup (service_description)); 00666 this->use_select_ = use_select; 00667 this->reuse_addr_ = reuse_addr; 00668 }
| ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_Strategy_Acceptor | ( | const ACE_PEER_ACCEPTOR_ADDR & | local_addr, | |
| ACE_Reactor * | reactor = ACE_Reactor::instance (), |
|||
| ACE_Creation_Strategy< SVC_HANDLER > * | cre_s = 0, |
|||
| ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > * | acc_s = 0, |
|||
| ACE_Concurrency_Strategy< SVC_HANDLER > * | con_s = 0, |
|||
| ACE_Scheduling_Strategy< SVC_HANDLER > * | sch_s = 0, |
|||
| const ACE_TCHAR | service_name[] = 0, |
|||
| const ACE_TCHAR | service_description[] = 0, |
|||
| int | use_select = 1, |
|||
| int | reuse_addr = 1 | |||
| ) | [inline] |
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 672 of file Acceptor.cpp.
00682 : creation_strategy_ (0), 00683 delete_creation_strategy_ (false), 00684 accept_strategy_ (0), 00685 delete_accept_strategy_ (false), 00686 concurrency_strategy_ (0), 00687 delete_concurrency_strategy_ (false), 00688 scheduling_strategy_ (0), 00689 delete_scheduling_strategy_ (false), 00690 service_name_ (0), 00691 service_description_ (0) 00692 { 00693 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor"); 00694 00695 if (this->open (addr, 00696 reactor, 00697 cre_s, 00698 acc_s, 00699 con_s, 00700 sch_s, 00701 service_name, 00702 service_description, 00703 use_select, 00704 reuse_addr) == -1) 00705 ACE_ERROR ((LM_ERROR, 00706 ACE_TEXT ("%p\n"), 00707 ACE_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"))); 00708 }
| ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::~ACE_Strategy_Acceptor | ( | void | ) | [inline, virtual] |
Close down the Strategy_Acceptor's resources.
Definition at line 803 of file Acceptor.cpp.
00804 { 00805 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Strategy_Acceptor"); 00806 ACE_OS::free ((void *) this->service_name_); 00807 ACE_OS::free ((void *) this->service_description_); 00808 this->handle_close (); 00809 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::accept_svc_handler | ( | SVC_HANDLER * | svc_handler | ) | [inline, 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 778 of file Acceptor.cpp.
00779 { 00780 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler"); 00781 return this->accept_strategy_->accept_svc_handler (svc_handler); 00782 }
| ACE_PEER_ACCEPTOR & ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::acceptor | ( | void | ) | const [inline, virtual] |
Return the underlying PEER_ACCEPTOR object.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 504 of file Acceptor.cpp.
00505 { 00506 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor"); 00507 return this->accept_strategy_->acceptor (); 00508 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::activate_svc_handler | ( | SVC_HANDLER * | svc_handler | ) | [inline, 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 794 of file Acceptor.cpp.
00795 { 00796 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler"); 00797 return this->concurrency_strategy_->activate_svc_handler 00798 (svc_handler, 00799 (void *) this); 00800 }
| void ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::dump | ( | void | ) | const [inline] |
Dump the state of an object.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 479 of file Acceptor.cpp.
00480 { 00481 #if defined (ACE_HAS_DUMP) 00482 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump"); 00483 00484 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00485 ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump (); 00486 this->creation_strategy_->dump (); 00487 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_creation_strategy_ = %d"), delete_creation_strategy_)); 00488 this->accept_strategy_->dump (); 00489 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_accept_strategy_ = %d"), delete_accept_strategy_)); 00490 this->concurrency_strategy_->dump (); 00491 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_concurrency_strategy_ = %d"), delete_concurrency_strategy_)); 00492 this->scheduling_strategy_->dump (); 00493 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_scheduling_strategy_ = %d"), delete_scheduling_strategy_)); 00494 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nservice_name_ = %s"), 00495 this->service_name_ == 0 ? ACE_TEXT ("<unknown>") : this->service_name_)); 00496 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nservice_description_ = %s"), 00497 this->service_description_ == 0 ? ACE_TEXT ("<unknown>") : this->service_description_)); 00498 this->service_addr_.dump (); 00499 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00500 #endif /* ACE_HAS_DUMP */ 00501 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::fini | ( | void | ) | [inline, protected, virtual] |
Calls {handle_close} when dynamically unlinked.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 855 of file Acceptor.cpp.
00856 { 00857 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini"); 00858 return this->ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close (); 00859 }
| ACE_HANDLE ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::get_handle | ( | void | ) | const [inline, virtual] |
Returns the listening acceptor's {ACE_HANDLE}.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 520 of file Acceptor.cpp.
00521 { 00522 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle"); 00523 return this->accept_strategy_->get_handle (); 00524 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::handle_close | ( | ACE_HANDLE | = ACE_INVALID_HANDLE, |
|
| ACE_Reactor_Mask | = ACE_Event_Handler::ALL_EVENTS_MASK | |||
| ) | [inline, 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 714 of file Acceptor.cpp.
00716 { 00717 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close"); 00718 // Guard against multiple closes. 00719 if (this->reactor () != 0) 00720 { 00721 ACE_HANDLE handle = this->get_handle (); 00722 00723 if (this->delete_creation_strategy_) 00724 delete this->creation_strategy_; 00725 this->delete_creation_strategy_ = false; 00726 this->creation_strategy_ = 0; 00727 00728 if (this->delete_accept_strategy_) 00729 delete this->accept_strategy_; 00730 this->delete_accept_strategy_ = false; 00731 this->accept_strategy_ = 0; 00732 00733 if (this->delete_concurrency_strategy_) 00734 delete this->concurrency_strategy_; 00735 this->delete_concurrency_strategy_ = false; 00736 this->concurrency_strategy_ = 0; 00737 00738 if (this->delete_scheduling_strategy_) 00739 delete this->scheduling_strategy_; 00740 this->delete_scheduling_strategy_ = false; 00741 this->scheduling_strategy_ = 0; 00742 00743 // We must use the <handle> obtained *before* we deleted the 00744 // accept_strategy_... 00745 00746 this->reactor ()->remove_handler 00747 (handle, 00748 ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); 00749 00750 // Set the Reactor to 0 so that we don't try to close down 00751 // again. 00752 this->reactor (0); 00753 } 00754 return 0; 00755 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::handle_signal | ( | int | signum, | |
| siginfo_t * | , | |||
| ucontext_t * | ||||
| ) | [inline, protected, virtual] |
Handle SIGINT.
Reimplemented from ACE_Event_Handler.
Definition at line 814 of file Acceptor.cpp.
00815 { 00816 ACE_Reactor::instance()->end_reactor_event_loop (); 00817 return 0; 00818 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::info | ( | ACE_TCHAR ** | buf, | |
| size_t | length | |||
| ) | const [inline, protected, virtual] |
Default version returns address info in {buf}.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 821 of file Acceptor.cpp.
00823 { 00824 ACE_TRACE ("ACE_Strategy_Acceptor::info"); 00825 00826 ACE_TCHAR buf[BUFSIZ]; 00827 ACE_TCHAR service_addr_str[BUFSIZ]; 00828 ACE_PEER_ACCEPTOR_ADDR addr; 00829 00830 if (this->acceptor ().get_local_addr (addr) == -1) 00831 return -1; 00832 else if (addr.addr_to_string (service_addr_str, 00833 sizeof service_addr_str) == -1) 00834 return -1; 00835 00836 // @@ Should add the protocol in... 00837 ACE_OS::sprintf (buf, 00838 ACE_TEXT ("%s\t %s #%s\n"), 00839 this->service_name_ == 0 00840 ? ACE_TEXT ("<unknown>") 00841 : this->service_name_, 00842 service_addr_str, 00843 this->service_description_ == 0 00844 ? ACE_TEXT ("<unknown>") 00845 : this->service_description_); 00846 00847 if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) 00848 return -1; 00849 else 00850 ACE_OS::strsncpy (*strp, buf, length); 00851 return static_cast<int> (ACE_OS::strlen (buf)); 00852 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::make_svc_handler | ( | SVC_HANDLER *& | sh | ) | [inline, 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 766 of file Acceptor.cpp.
00767 { 00768 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler"); 00769 return this->creation_strategy_->make_svc_handler (sh); 00770 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::open | ( | const ACE_PEER_ACCEPTOR_ADDR & | local_addr, | |
| ACE_Reactor * | reactor = ACE_Reactor::instance (), |
|||
| ACE_Creation_Strategy< SVC_HANDLER > * | cre_s = 0, |
|||
| ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > * | acc_s = 0, |
|||
| ACE_Concurrency_Strategy< SVC_HANDLER > * | con_s = 0, |
|||
| ACE_Scheduling_Strategy< SVC_HANDLER > * | sch_s = 0, |
|||
| const ACE_TCHAR * | service_name = 0, |
|||
| const ACE_TCHAR * | service_description = 0, |
|||
| int | use_select = 1, |
|||
| int | reuse_addr = 1 | |||
| ) | [inline, 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 546 of file Acceptor.cpp.
00556 { 00557 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open"); 00558 00559 if (this->service_name_ == 0 && service_name != 0) 00560 ACE_ALLOCATOR_RETURN (this->service_name_, 00561 ACE_OS::strdup (service_name), 00562 -1); 00563 if (this->service_description_ == 0 && service_description != 0) 00564 ACE_ALLOCATOR_RETURN (this->service_description_, 00565 ACE_OS::strdup (service_description), 00566 -1); 00567 this->reactor (reactor); 00568 00569 // Must supply a valid Reactor to Acceptor::open()... 00570 if (reactor == 0) 00571 { 00572 errno = EINVAL; 00573 return -1; 00574 } 00575 00576 // Initialize the creation strategy. 00577 00578 if (cre_s == 0) 00579 { 00580 ACE_NEW_RETURN (cre_s, 00581 CREATION_STRATEGY, 00582 -1); 00583 this->delete_creation_strategy_ = true; 00584 } 00585 this->creation_strategy_ = cre_s; 00586 00587 // Initialize the accept strategy. 00588 00589 if (acc_s == 0) 00590 { 00591 ACE_NEW_RETURN (acc_s, 00592 ACCEPT_STRATEGY (this->reactor ()), 00593 -1); 00594 this->delete_accept_strategy_ = true; 00595 } 00596 this->accept_strategy_ = acc_s; 00597 00598 if (this->accept_strategy_->open (local_addr, reuse_addr) == -1) 00599 return -1; 00600 00601 // Set the peer acceptor's handle into non-blocking mode. This is a 00602 // safe-guard against the race condition that can otherwise occur 00603 // between the time when <select> indicates that a passive-mode 00604 // socket handle is "ready" and when we call <accept>. During this 00605 // interval, the client can shutdown the connection, in which case, 00606 // the <accept> call can hang! 00607 if (this->accept_strategy_->acceptor ().enable (ACE_NONBLOCK) != 0) 00608 return -1; 00609 00610 // Initialize the concurrency strategy. 00611 00612 if (con_s == 0) 00613 { 00614 ACE_NEW_RETURN (con_s, 00615 CONCURRENCY_STRATEGY, 00616 -1); 00617 this->delete_concurrency_strategy_ = true; 00618 } 00619 this->concurrency_strategy_ = con_s; 00620 00621 // Initialize the scheduling strategy. 00622 00623 if (sch_s == 0) 00624 { 00625 ACE_NEW_RETURN (sch_s, 00626 SCHEDULING_STRATEGY, 00627 -1); 00628 this->delete_scheduling_strategy_ = true; 00629 } 00630 this->scheduling_strategy_ = sch_s; 00631 00632 this->use_select_ = use_select; 00633 00634 return this->reactor ()->register_handler 00635 (this, 00636 ACE_Event_Handler::ACCEPT_MASK); 00637 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::open | ( | const ACE_PEER_ACCEPTOR_ADDR & | local_addr, | |
| ACE_Reactor * | reactor, | |||
| int | flags = 0, |
|||
| int | use_select = 1, |
|||
| int | reuse_addr = 1 | |||
| ) | [inline, 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, instead 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 532 of file Acceptor.cpp.
| ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::operator ACE_PEER_ACCEPTOR & | ( | ) | const [inline, virtual] |
Return the underlying PEER_ACCEPTOR object.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 511 of file Acceptor.cpp.
00512 { 00513 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &"); 00514 return this->accept_strategy_->acceptor (); 00515 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::resume | ( | void | ) | [inline, virtual] |
This method delegates to the {Scheduling_Strategy}'s {resume} method.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 467 of file Acceptor.cpp.
00468 { 00469 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume"); 00470 00471 // First resume ourselves. 00472 if (ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume () == -1) 00473 return -1; 00474 else // Then resume the SVC_HANDLER's we've created. 00475 return this->scheduling_strategy_->resume (); 00476 }
| int ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::suspend | ( | void | ) | [inline, virtual] |
This method delegates to the {Scheduling_Strategy}'s {suspend} method.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 455 of file Acceptor.cpp.
00456 { 00457 ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend"); 00458 00459 // First suspend the SVC_HANDLER's we've created. 00460 if (this->scheduling_strategy_->suspend () == -1) 00461 return -1; 00462 else // Then suspend ourselves. 00463 return ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend (); 00464 }
ACCEPT_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::accept_strategy_ [protected] |
Accept strategy for an {Acceptor}.
Definition at line 469 of file Acceptor.h.
| ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.
Definition at line 392 of file Acceptor.h.
CONCURRENCY_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::concurrency_strategy_ [protected] |
Concurrency strategy for an {Acceptor}.
Definition at line 476 of file Acceptor.h.
CREATION_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::creation_strategy_ [protected] |
Creation strategy for an Acceptor.
Definition at line 462 of file Acceptor.h.
bool ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::delete_accept_strategy_ [protected] |
true if {Acceptor} created the accept strategy and thus should delete it, else false.
Definition at line 473 of file Acceptor.h.
bool ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::delete_concurrency_strategy_ [protected] |
true if {Acceptor} created the concurrency strategy and thus should delete it, else false.
Definition at line 480 of file Acceptor.h.
bool ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::delete_creation_strategy_ [protected] |
true if {Acceptor} created the creation strategy and thus should delete it, else false.
Definition at line 466 of file Acceptor.h.
bool ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::delete_scheduling_strategy_ [protected] |
true if {Acceptor} created the scheduling strategy and thus should delete it, else false.
Definition at line 487 of file Acceptor.h.
SCHEDULING_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::scheduling_strategy_ [protected] |
Scheduling strategy for an {Acceptor}.
Definition at line 483 of file Acceptor.h.
ACE_PEER_ACCEPTOR_ADDR ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::service_addr_ [protected] |
Address that the {Strategy_Acceptor} uses to listen for connections.
Definition at line 499 of file Acceptor.h.
ACE_TCHAR* ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::service_description_ [protected] |
Description of the service.
Definition at line 495 of file Acceptor.h.
ACE_TCHAR* ACE_Strategy_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::service_name_ [protected] |
Name of the service.
Definition at line 492 of file Acceptor.h.
1.6.1