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 &,
ACE_Reactor * = ACE_Service_Config::reactor (),
ACE_Concurrency_Strategy<SVC_HANDLER> * = 0
);
int open (
const ACE_PEER_ACCEPTOR_ADDR &,
ACE_Reactor * = ACE_Service_Config::reactor (),
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
);
virtual int cancel (void);
virtual operator ACE_PEER_ACCEPTOR &() const;
virtual ACE_PEER_ACCEPTOR &acceptor (void) const;
ACE_Reactor *reactor (void) const;
void reactor (ACE_Reactor *);
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 register_handler (
SVC_HANDLER *svc_handler,
const ACE_Synch_Options &options,
int restart
);
virtual ACE_HANDLE get_handle (void) const;
virtual int handle_close (
ACE_HANDLE = ACE_INVALID_HANDLE,
ACE_Reactor_Mask = ACE_Event_Handler::RWE_MASK
);
virtual int handle_input (ACE_HANDLE);
virtual int handle_timeout (
const ACE_Time_Value &tv,
const void *arg
);
virtual int init (int argc, char *argv[]);
virtual int fini (void);
virtual int info (char **, size_t) const;
virtual int suspend (void);
virtual int resume (void);
private:
ACE_Reactor *reactor_;
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 acceptor except
that this class doesn't need a Creation_Strategy (since the
user supplies the SVC_HANDLER) or an Accept_Strategy (since
this class only accepts one connection and then removes all
traces (e.g., from the ACE_Reactor).
Initialization and termination methods.
ACE_Oneshot_Acceptor (void);
"Do-nothing" constructor.
ACE_Oneshot_Acceptor (
const ACE_PEER_ACCEPTOR_ADDR &,
ACE_Reactor * = ACE_Service_Config::reactor (),
ACE_Concurrency_Strategy<SVC_HANDLER> * = 0
);
Initialize the appropriate strategies for concurrency and
creation and then register this at the designated local_addr.
int open (
const ACE_PEER_ACCEPTOR_ADDR &,
ACE_Reactor * = ACE_Service_Config::reactor (),
ACE_Concurrency_Strategy<SVC_HANDLER> * = 0
);
Initialize the appropriate strategies for concurrency and
creation and then register this at the designated local_addr.
virtual ~ACE_Oneshot_Acceptor (void);
Close down the Oneshot_Acceptor.
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
);
Create a SVC_HANDLER, accept the connection into the SVC_HANDLER,
and activate the SVC_HANDLER.
virtual int cancel (void);
Cancel a oneshot acceptor that was started asynchronously.
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.
ACE_Reactor *reactor (void) const;
Get the underlying Reactor *.
void reactor (ACE_Reactor *);
Set the underlying Reactor *.
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
Demultiplexing hooks.
virtual ACE_HANDLE get_handle (void) const;
Returns the listening acceptor's ACE_HANDLE.
virtual int handle_close (
ACE_HANDLE = ACE_INVALID_HANDLE,
ACE_Reactor_Mask = ACE_Event_Handler::RWE_MASK
);
Perform termination activities when this is removed from the
reactor_.
virtual int handle_input (ACE_HANDLE);
Accept one connection from a client and activates the
SVC_HANDLER.
virtual int handle_timeout (
const ACE_Time_Value &tv,
const void *arg
);
Called when an acceptor times out...
Dynamic linking hooks.
virtual int init (int argc, char *argv[]);
Default version does no work and returns -1. Must be overloaded
by application developer to do anything meaningful.
virtual int fini (void);
Default version does no work and returns -1. Must be overloaded
by application developer to do anything meaningful.
virtual int info (char **, size_t) const;
Default version returns address info in buf.
Service management hooks.
virtual int suspend (void);
Default version does no work and returns -1. Must be overloaded
by application developer to do anything meaningful.
virtual int resume (void);
Default version does no work and returns -1. Must be overloaded
by application developer to do anything meaningful.
AUTHOR
Doug Schmidt
LIBRARY
ace