Public Types | Public Member Functions | Public Attributes | Protected Attributes

ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 > Class Template Reference

Defines the interface for specifying a passive connection acceptance strategy for a SVC_HANDLER. More...

#include <Strategies_T.h>

Collaboration diagram for ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef ACE_PEER_ACCEPTOR_ADDR addr_type
typedef ACE_PEER_ACCEPTOR acceptor_type
typedef SVC_HANDLER handler_type
typedef SVC_HANDLER::stream_type stream_type

Public Member Functions

 ACE_Accept_Strategy (ACE_Reactor *reactor=ACE_Reactor::instance())
 Default constructor.
 ACE_Accept_Strategy (const ACE_PEER_ACCEPTOR_ADDR &local_addr, bool restart=false, ACE_Reactor *reactor=ACE_Reactor::instance())
 Initialize the peer_acceptor_ with local_addr.
virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, bool reuse_addr=false)
virtual ACE_HANDLE get_handle (void) const
 Return the underlying ACE_HANDLE of the <peer_acceptor_>.
virtual ACE_PEER_ACCEPTOR & acceptor (void) const
 Return a reference to the <peer_acceptor_>.
virtual ~ACE_Accept_Strategy (void)
virtual int accept_svc_handler (SVC_HANDLER *)
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Protected Attributes

ACE_PEER_ACCEPTOR peer_acceptor_
 Factory that establishes connections passively.
ACE_Reactorreactor_
 Pointer to the reactor used by the Acceptor.
bool reuse_addr_
 Needed to reopen the socket if <accept> fails.
ACE_PEER_ACCEPTOR_ADDR peer_acceptor_addr_
 Needed to reopen the socket if <accept> fails.

Detailed Description

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
class ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >

Defines the interface for specifying a passive connection acceptance strategy for a SVC_HANDLER.

This class provides a strategy that manages passive connection acceptance of a client.

Definition at line 498 of file Strategies_T.h.


Member Typedef Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_PEER_ACCEPTOR ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::acceptor_type

Definition at line 504 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_PEER_ACCEPTOR_ADDR ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::addr_type

Definition at line 503 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef SVC_HANDLER ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::handler_type

Definition at line 505 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef SVC_HANDLER::stream_type ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::stream_type

Definition at line 506 of file Strategies_T.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_Accept_Strategy ( ACE_Reactor reactor = ACE_Reactor::instance ()  ) 

Default constructor.

Definition at line 124 of file Strategies_T.inl.

  : reactor_ (reactor)
{
  ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy");
}

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_Accept_Strategy ( const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
bool  restart = false,
ACE_Reactor reactor = ACE_Reactor::instance () 
)

Initialize the peer_acceptor_ with local_addr.

Definition at line 323 of file Strategies_T.cpp.

    : reactor_ (reactor)
{
  ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy");

  if (this->open (local_addr, reuse_addr) == -1)
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("%p\n"),
                ACE_TEXT ("open")));
}

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

Definition at line 1289 of file Strategies_T.cpp.

{
  ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy");

  // Close the underlying acceptor.
  this->peer_acceptor_.close ();
}


Member Function Documentation

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

The default behavior delegates to the <accept> method of the PEER_ACCEPTOR.

Definition at line 338 of file Strategies_T.cpp.

{
  ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");

  // Try to find out if the implementation of the reactor that we are
  // using requires us to reset the event association for the newly
  // created handle. This is because the newly created handle will
  // inherit the properties of the listen handle, including its event
  // associations.
  bool reset_new_handle = this->reactor_->uses_event_associations ();

  if (this->peer_acceptor_.accept (svc_handler->peer (), // stream
                                   0, // remote address
                                   0, // timeout
                                   1, // restart
                                   reset_new_handle  // reset new handler
                                   ) == -1)
    {
      // Ensure that errno is preserved in case the svc_handler
      // close() method resets it
      ACE_Errno_Guard error(errno);

      // Close down handler to avoid memory leaks.
      svc_handler->close (CLOSE_DURING_NEW_CONNECTION);

      return -1;
    }
  else
    return 0;
}

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

Return a reference to the <peer_acceptor_>.

Definition at line 1305 of file Strategies_T.cpp.

{
  ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
  return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
}

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

Dump the state of an object.

Definition at line 1312 of file Strategies_T.cpp.

{
#if defined (ACE_HAS_DUMP)
  ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
#endif /* ACE_HAS_DUMP */
}

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

Return the underlying ACE_HANDLE of the <peer_acceptor_>.

Definition at line 1298 of file Strategies_T.cpp.

{
  ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
  return this->peer_acceptor_.get_handle ();
}

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::open ( const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
bool  reuse_addr = false 
) [virtual]

Initialize the <peer_acceptor_> with local_addr, indicating whether to reuse_addr if it's already in use.

Definition at line 304 of file Strategies_T.cpp.

{
  this->reuse_addr_ = reuse_addr;
  this->peer_acceptor_addr_ = local_addr;
  if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1)
    return -1;

  // Set the peer acceptor's handle into non-blocking mode.  This is a
  // safe-guard against the race condition that can otherwise occur
  // between the time when <select> indicates that a passive-mode
  // socket handle is "ready" and when we call <accept>.  During this
  // interval, the client can shutdown the connection, in which case,
  // the <accept> call can hang!
  this->peer_acceptor_.enable (ACE_NONBLOCK);
  return 0;
}


Member Data Documentation

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

Declare the dynamic allocation hooks.

Definition at line 539 of file Strategies_T.h.

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

Factory that establishes connections passively.

Definition at line 543 of file Strategies_T.h.

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

Needed to reopen the socket if <accept> fails.

Definition at line 552 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Reactor* ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::reactor_ [protected]

Pointer to the reactor used by the Acceptor.

Definition at line 546 of file Strategies_T.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
bool ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::reuse_addr_ [protected]

Needed to reopen the socket if <accept> fails.

Definition at line 549 of file Strategies_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines