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

ACE_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_Acceptor:

Inheritance graph
[legend]
Collaboration diagram for ACE_Acceptor:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Acceptor (ACE_Reactor *=0, int use_select=1)
 "Do-nothing" constructor. More...

 ACE_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, ACE_Reactor *=ACE_Reactor::instance(), int flags=0, int use_select=1, int reuse_addr=1)
 Initialize and register <this> with the Reactor and listen for connection requests at the designated <local_addr>. More...

int open (const ACE_PEER_ACCEPTOR_ADDR &, ACE_Reactor *=ACE_Reactor::instance(), int flags=0, int use_select=1, int reuse_addr=1)
 Initialize and register <this> with the Reactor and listen for connection requests at the designated <local_addr>. More...

virtual ~ACE_Acceptor (void)
 Close down the 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...

virtual int close (void)
 Close down the Acceptor. More...

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

virtual int suspend (void)
 This method calls <Reactor::suspend>. More...

virtual int resume (void)
 This method calls <Reactor::resume>. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

virtual int make_svc_handler (SVC_HANDLER *&sh)
 Bridge method for creating a SVC_HANDLER. More...

virtual int accept_svc_handler (SVC_HANDLER *svc_handler)
 Bridge method for accepting the new connection into the <svc_handler>. More...

virtual int activate_svc_handler (SVC_HANDLER *svc_handler)
 Bridge method for activating a <svc_handler> with the appropriate concurrency strategy. More...

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_input (ACE_HANDLE)
 Accepts all pending connections from clients, and creates and activates SVC_HANDLERs. More...

virtual int init (int argc, ACE_TCHAR *argv[])
 Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful. More...

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

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


Protected Attributes

ACE_PEER_ACCEPTOR peer_acceptor_
 Concrete factory for accepting connections from clients... More...

ACE_PEER_ACCEPTOR_ADDR peer_acceptor_addr_
 Needed to reopen the socket if <accept> fails. More...

int flags_
 Flags that indicate how <SVC_HANDLER>'s should be initialized prior to being activated. More...

int use_select_
 Flag that indicates whether it shall use <select> in the <accept>-loop. More...

int reuse_addr_
 Needed to reopen the socket if <accept> fails. More...


Detailed Description

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
class ACE_Acceptor< SVC_HANDLER, >

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

Implements the basic strategy for passively establishing connections with clients. An ACE_Acceptor is parameterized by concrete types that conform to the interfaces of PEER_ACCEPTOR and SVC_HANDLER. The PEER_ACCEPTOR is instantiated with a transport mechanism that passively establishes connections. The SVC_HANDLER is instantiated with a concrete type that performs the application-specific service. An ACE_Acceptor inherits from ACE_Service_Object, which in turn inherits from ACE_Event_Handler. This enables the ACE_Reactor to dispatch the ACE_Acceptor's handle_input method when connection events occur. The handle_input method performs the ACE_Acceptor's default creation, connection establishment, and service activation strategies. These strategies can be overridden by subclasses individually or as a group.


Constructor & Destructor Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Acceptor< SVC_HANDLER, >::ACE_Acceptor ACE_Reactor   = 0,
int    use_select = 1
 

"Do-nothing" constructor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Acceptor< SVC_HANDLER, >::ACE_Acceptor const ACE_PEER_ACCEPTOR_ADDR &    local_addr,
ACE_Reactor   = ACE_Reactor::instance (),
int    flags = 0,
int    use_select = 1,
int    reuse_addr = 1
 

Initialize and register <this> with the Reactor and listen for connection requests at the designated <local_addr>.

<flags> indicates how <SVC_HANDLER>'s should be initialized prior to being activated. Right now, the only flag that is processed is <ACE_NONBLOCK>, which enabled non-blocking I/O on the <SVC_HANDLER> when it is opened. If <use_select> is non-zero then <select> is used to determine when to break out of the <accept> loop. <reuse_addr> is passed down to the <PEER_ACCEPTOR>. If it is non-zero this will allow the OS to reuse this listen port.

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

Close down the Acceptor's resources.


Member Function Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
virtual int ACE_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.

Reimplemented in ACE_Strategy_Acceptor.

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

Return the underlying PEER_ACCEPTOR object.

Reimplemented in ACE_Strategy_Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
virtual int ACE_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 making the SVC_HANDLER as an "active object" via multi-threading or multi-processing).

Reimplemented in ACE_Strategy_Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
virtual int ACE_Acceptor< SVC_HANDLER, >::close void    [virtual]
 

Close down the Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
void ACE_Acceptor< SVC_HANDLER, >::dump void    const
 

Dump the state of an object.

Reimplemented in ACE_Strategy_Acceptor.

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

Calls <handle_close>.

Reimplemented from ACE_Shared_Object.

Reimplemented in ACE_Strategy_Acceptor.

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

Returns the listening acceptor's <ACE_HANDLE>.

Reimplemented from ACE_Event_Handler.

Reimplemented in ACE_Strategy_Acceptor.

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

Perform termination activities when <this> is removed from the <reactor>.

Reimplemented from ACE_Event_Handler.

Reimplemented in ACE_Strategy_Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
virtual int ACE_Acceptor< SVC_HANDLER, >::handle_input ACE_HANDLE    fd [protected, virtual]
 

Accepts all pending connections from clients, and creates and activates SVC_HANDLERs.

Reimplemented from ACE_Event_Handler.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
virtual int ACE_Acceptor< SVC_HANDLER, >::info ACE_TCHAR **    strp,
size_t    length
const [protected, virtual]
 

Default version returns address info in <buf>.

Reimplemented from ACE_Shared_Object.

Reimplemented in ACE_Strategy_Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
virtual int ACE_Acceptor< SVC_HANDLER, >::init int    argc,
ACE_TCHAR   argv[]
[protected, virtual]
 

Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.

Reimplemented from ACE_Shared_Object.

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

Bridge method for creating a SVC_HANDLER.

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 in ACE_Strategy_Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Acceptor< SVC_HANDLER, >::open const ACE_PEER_ACCEPTOR_ADDR &   ,
ACE_Reactor   = ACE_Reactor::instance (),
int    flags = 0,
int    use_select = 1,
int    reuse_addr = 1
 

Initialize and register <this> with the Reactor and listen for connection requests at the designated <local_addr>.

<flags> indicates how <SVC_HANDLER>'s should be initialized prior to being activated. Right now, the only flag that is processed is <ACE_NONBLOCK>, which enables non-blocking I/O on the <SVC_HANDLER> when it is opened. If <use_select> is non-zero then <select> is used to determine when to break out of the <accept> loop. <reuse_addr> is passed down to the <PEER_ACCEPTOR>. If it is non-zero this will allow the OS to reuse this listen port.

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

Return the underlying PEER_ACCEPTOR object.

Reimplemented in ACE_Strategy_Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
virtual int ACE_Acceptor< SVC_HANDLER, >::resume void    [virtual]
 

This method calls <Reactor::resume>.

Reimplemented from ACE_Service_Object.

Reimplemented in ACE_Strategy_Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
virtual int ACE_Acceptor< SVC_HANDLER, >::suspend void    [virtual]
 

This method calls <Reactor::suspend>.

Reimplemented from ACE_Service_Object.

Reimplemented in ACE_Strategy_Acceptor.


Member Data Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Acceptor::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented in ACE_Strategy_Acceptor.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Acceptor::flags_ [protected]
 

Flags that indicate how <SVC_HANDLER>'s should be initialized prior to being activated.

Right now, the only flag that is processed is <ACE_NONBLOCK>, which enabled non-blocking I/O on the <SVC_HANDLER> when it is opened.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR ACE_Acceptor::peer_acceptor_ [protected]
 

Concrete factory for accepting connections from clients...

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR_ADDR ACE_Acceptor::peer_acceptor_addr_ [protected]
 

Needed to reopen the socket if <accept> fails.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Acceptor::reuse_addr_ [protected]
 

Needed to reopen the socket if <accept> fails.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Acceptor::use_select_ [protected]
 

Flag that indicates whether it shall use <select> in the <accept>-loop.


The documentation for this class was generated from the following file:
Generated on Thu May 23 00:15:07 2002 for ACE by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001