NAME

ACE_Oneshot_Acceptor - Generic factory for passively connecting clients and creating exactly one service handler (SVC_HANDLER).

SYNOPSIS

#include <ace/Acceptor.h>

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> class ACE_Oneshot_Acceptor : public ACE_Service_Object { public: ACE_Oneshot_Acceptor (void); ACE_Oneshot_Acceptor ( const ACE_PEER_ACCEPTOR_ADDR &local_addr, ACE_Reactor *reactor = ACE_Reactor::instance (), ACE_Concurrency_Strategy<SVC_HANDLER> * = 0 ); int open ( const ACE_PEER_ACCEPTOR_ADDR &, ACE_Reactor *reactor = ACE_Reactor::instance (), ACE_Concurrency_Strategy<SVC_HANDLER> * = 0 ); virtual ~ACE_Oneshot_Acceptor (void); virtual int accept ( SVC_HANDLER * = 0, ACE_PEER_ACCEPTOR_ADDR *remote_addr = 0, const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults, int restart = 1, int reset_new_handle = 0 ); virtual int cancel (void); virtual operator ACE_PEER_ACCEPTOR &() const; virtual ACE_PEER_ACCEPTOR &acceptor (void) const; virtual int close (void); void dump (void) const; ACE_ALLOC_HOOK_DECLARE; protected: virtual int activate_svc_handler (SVC_HANDLER *svc_handler); int shared_accept ( SVC_HANDLER *svc_handler, ACE_PEER_ACCEPTOR_ADDR *remote_addr, ACE_Time_Value *timeout, int restart, int reset_new_handle ); virtual ACE_HANDLE get_handle (void) const; virtual int handle_close ( ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK ); virtual int handle_input (ACE_HANDLE); virtual int handle_timeout ( const ACE_Time_Value &tv, const void *arg ); virtual int init (int argc, ASYS_TCHAR *argv[]); virtual int fini (void); virtual int info (ASYS_TCHAR **, size_t) const; virtual int suspend (void); virtual int resume (void); private: int register_handler ( SVC_HANDLER *svc_handler, const ACE_Synch_Options &options, int restart ); SVC_HANDLER *svc_handler_; int restart_; ACE_PEER_ACCEPTOR peer_acceptor_; ACE_Concurrency_Strategy<SVC_HANDLER> *concurrency_strategy_; int delete_concurrency_strategy_; };

DESCRIPTION

This class works similarly to the regular ACE_Acceptor, with the following differences:

1. This class doesn't automagically register this with the ACE_Reactor since it expects to have its accept method called directly. However, it stashes the ACE_Reactor pointer away in case it's needed later to finish accepting a connection asynchronously.

2. The class doesn't need an ACE_Creation_Strategy (since the user supplies the SVC_HANDLER) or an ACE_Accept_Strategy (since this class only accepts one connection and then removes all traces of itself from the ACE_Reactor if it was registered for asynchronous accepts).

Initialization and termination methods.

ACE_Oneshot_Acceptor (void);

ACE_Oneshot_Acceptor (
    const ACE_PEER_ACCEPTOR_ADDR &local_addr,
    ACE_Reactor *reactor = ACE_Reactor::instance (),
    ACE_Concurrency_Strategy<SVC_HANDLER> * = 0
    );

int open (
    const ACE_PEER_ACCEPTOR_ADDR &,
    ACE_Reactor *reactor = ACE_Reactor::instance (),
    ACE_Concurrency_Strategy<SVC_HANDLER> * = 0
    );

virtual ~ACE_Oneshot_Acceptor (void);

Explicit factory operation.

virtual int accept (
    SVC_HANDLER * = 0,
    ACE_PEER_ACCEPTOR_ADDR *remote_addr = 0,
    const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults,
    int restart = 1,
    int reset_new_handle = 0
    );

virtual int cancel (void);

virtual operator ACE_PEER_ACCEPTOR &() const;

virtual ACE_PEER_ACCEPTOR &acceptor (void) const;

virtual int close (void);

void dump (void) const;

ACE_ALLOC_HOOK_DECLARE;

Demultiplexing hooks.

virtual ACE_HANDLE get_handle (void) const;

virtual int handle_close (
    ACE_HANDLE = ACE_INVALID_HANDLE,
    ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK
    );

virtual int handle_input (ACE_HANDLE);

virtual int handle_timeout (
    const ACE_Time_Value &tv,
    const void *arg
    );

Dynamic linking hooks.

virtual int init (int argc, ASYS_TCHAR *argv[]);

virtual int fini (void);

virtual int info (ASYS_TCHAR **, size_t) const;

Service management hooks.

virtual int suspend (void);

virtual int resume (void);

AUTHOR

Doug Schmidt

LIBRARY

ace