#include <Connector.h>
Public Types | |
typedef SVC_HANDLER::addr_type | addr_type |
typedef ACE_PEER_CONNECTOR | connector_type |
typedef SVC_HANDLER | handler_type |
typedef SVC_HANDLER::stream_type | stream_type |
typedef ACE_PEER_CONNECTOR::PEER_ADDR | peer_addr_type |
typedef ACE_PEER_CONNECTOR_ADDR | ACE_PEER_ADDR_TYPEDEF |
Public Member Functions | |
ACE_Connector (ACE_Reactor *r=ACE_Reactor::instance(), int flags=0) | |
virtual int | open (ACE_Reactor *r=ACE_Reactor::instance(), int flags=0) |
virtual | ~ACE_Connector (void) |
Shutdown a connector and release resources. | |
virtual int | connect (SVC_HANDLER *&svc_handler, const ACE_PEER_CONNECTOR_ADDR &remote_addr, const ACE_Synch_Options &synch_options=ACE_Synch_Options::defaults, const ACE_PEER_CONNECTOR_ADDR &local_addr=(peer_addr_type &) ACE_PEER_CONNECTOR_ADDR_ANY, int reuse_addr=0, int flags=O_RDWR, int perms=0) |
virtual int | connect (SVC_HANDLER *&svc_handler_hint, SVC_HANDLER *&svc_handler, const ACE_PEER_CONNECTOR_ADDR &remote_addr, const ACE_Synch_Options &synch_options=ACE_Synch_Options::defaults, const ACE_PEER_CONNECTOR_ADDR &local_addr=(peer_addr_type &) ACE_PEER_CONNECTOR_ADDR_ANY, int reuse_addr=0, int flags=O_RDWR, int perms=0) |
virtual int | connect_n (size_t n, SVC_HANDLER *svc_handlers[], ACE_PEER_CONNECTOR_ADDR remote_addrs[], ACE_TCHAR *failed_svc_handlers=0, const ACE_Synch_Options &synch_options=ACE_Synch_Options::defaults) |
virtual int | cancel (SVC_HANDLER *svc_handler) |
virtual int | close (void) |
virtual ACE_PEER_CONNECTOR & | connector (void) const |
Return the underlying PEER_CONNECTOR object. | |
virtual void | initialize_svc_handler (ACE_HANDLE handle, SVC_HANDLER *svc_handler) |
Initialize Svc_Handler. | |
virtual void | reactor (ACE_Reactor *reactor) |
Set Reactor. | |
virtual ACE_Reactor * | reactor (void) const |
Get Reactor. | |
void | dump (void) const |
Dump the state of an object. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Types | |
typedef ACE_NonBlocking_Connect_Handler < SVC_HANDLER > | NBCH |
Protected Member Functions | |
virtual int | make_svc_handler (SVC_HANDLER *&sh) |
virtual int | connect_svc_handler (SVC_HANDLER *&svc_handler, const ACE_PEER_CONNECTOR_ADDR &remote_addr, ACE_Time_Value *timeout, const ACE_PEER_CONNECTOR_ADDR &local_addr, int reuse_addr, int flags, int perms) |
virtual int | connect_svc_handler (SVC_HANDLER *&svc_handler, SVC_HANDLER *&sh_copy, const ACE_PEER_CONNECTOR_ADDR &remote_addr, ACE_Time_Value *timeout, const ACE_PEER_CONNECTOR_ADDR &local_addr, int reuse_addr, int flags, int perms) |
virtual int | activate_svc_handler (SVC_HANDLER *svc_handler) |
int | nonblocking_connect (SVC_HANDLER *, const ACE_Synch_Options &) |
Creates and registers ACE_NonBlocking_Connect_Handler. | |
virtual int | connect_i (SVC_HANDLER *&svc_handler, SVC_HANDLER **sh_copy, const ACE_PEER_CONNECTOR_ADDR &remote_addr, const ACE_Synch_Options &synch_options, const ACE_PEER_CONNECTOR_ADDR &local_addr, int reuse_addr, int flags, int perms) |
Implementation of the connect methods. | |
ACE_Unbounded_Set< ACE_HANDLE > & | non_blocking_handles (void) |
virtual int | init (int argc, ACE_TCHAR *argv[]) |
virtual int | fini (void) |
Calls handle_close() to shutdown the Connector gracefully. | |
virtual int | info (ACE_TCHAR **strp, size_t length) const |
Default version returns address info in buf. | |
virtual int | suspend (void) |
virtual int | resume (void) |
Private Attributes | |
ACE_PEER_CONNECTOR | connector_ |
This is the peer connector factory. | |
int | flags_ |
ACE_Reactor * | reactor_ |
Pointer to the Reactor. | |
ACE_Unbounded_Set< ACE_HANDLE > | non_blocking_handles_ |
Handle set representing the non-blocking connects in progress. |
Implements the strategy for actively establishing connections with clients. An ACE_Connector is parameterized by concrete types that conform to the interfaces of PEER_CONNECTOR and SVC_HANDLER. The PEER_CONNECTOR is instantiated with a transport mechanism that actively establishes connections. The SVC_HANDLER is instantiated with a concrete type that performs the application-specific service. Both blocking and non-blocking connects are supported. Further, non-blocking connects support timeouts.
typedef ACE_PEER_CONNECTOR_ADDR ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::ACE_PEER_ADDR_TYPEDEF |
typedef SVC_HANDLER::addr_type ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::addr_type |
typedef ACE_PEER_CONNECTOR ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connector_type |
typedef SVC_HANDLER ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::handler_type |
typedef ACE_NonBlocking_Connect_Handler<SVC_HANDLER> ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::NBCH [protected] |
typedef ACE_PEER_CONNECTOR::PEER_ADDR ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::peer_addr_type |
typedef SVC_HANDLER::stream_type ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::stream_type |
ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::ACE_Connector | ( | ACE_Reactor * | r = ACE_Reactor::instance() , |
|
int | flags = 0 | |||
) |
Initialize a connector. 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.
virtual ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::~ACE_Connector | ( | void | ) | [virtual] |
Shutdown a connector and release resources.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::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 creating the SVC_HANDLER as an "active object" via multi-threading or multi-processing).
Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::cancel | ( | SVC_HANDLER * | svc_handler | ) | [virtual] |
Cancel the svc_handler that was started asynchronously. Note that this is the only case when the Connector does not actively close the svc_handler. It is left up to the caller of <cancel> to decide the fate of the svc_handler.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::close | ( | void | ) | [virtual] |
Close down the Connector. All pending non-blocking connects are canceled and the corresponding svc_handler is closed.
Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connect | ( | SVC_HANDLER *& | svc_handler_hint, | |
SVC_HANDLER *& | svc_handler, | |||
const ACE_PEER_CONNECTOR_ADDR & | remote_addr, | |||
const ACE_Synch_Options & | synch_options = ACE_Synch_Options::defaults , |
|||
const ACE_PEER_CONNECTOR_ADDR & | local_addr = (peer_addr_type &) ACE_PEER_CONNECTOR_ADDR_ANY , |
|||
int | reuse_addr = 0 , |
|||
int | flags = O_RDWR , |
|||
int | perms = 0 | |||
) | [virtual] |
This is a variation on the previous <connect> method. On cached connectors the svc_handler_hint variable can be used as a hint for future lookups. Since this variable is modified in the context of the internal cache its use is thread-safe. But the actual svc_handler for the current connection is returned in the second parameter svc_handler. If the connection fails the <close> hook on the svc_handler will be called automatically to prevent resource leaks.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connect | ( | SVC_HANDLER *& | svc_handler, | |
const ACE_PEER_CONNECTOR_ADDR & | remote_addr, | |||
const ACE_Synch_Options & | synch_options = ACE_Synch_Options::defaults , |
|||
const ACE_PEER_CONNECTOR_ADDR & | local_addr = (peer_addr_type &) ACE_PEER_CONNECTOR_ADDR_ANY , |
|||
int | reuse_addr = 0 , |
|||
int | flags = O_RDWR , |
|||
int | perms = 0 | |||
) | [virtual] |
Initiate connection of svc_handler to peer at remote_addr using synch_options. If the caller wants to designate the selected local_addr they can (and can also insist that the local_addr be reused by passing a value reuse_addr == 1). flags and perms can be used to pass any flags that are needed to perform specific operations such as opening a file within connect with certain permissions. If the connection fails the <close> hook on the svc_handler will be called automatically to prevent resource leaks.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connect_i | ( | SVC_HANDLER *& | svc_handler, | |
SVC_HANDLER ** | sh_copy, | |||
const ACE_PEER_CONNECTOR_ADDR & | remote_addr, | |||
const ACE_Synch_Options & | synch_options, | |||
const ACE_PEER_CONNECTOR_ADDR & | local_addr, | |||
int | reuse_addr, | |||
int | flags, | |||
int | perms | |||
) | [protected, virtual] |
Implementation of the connect methods.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connect_n | ( | size_t | n, | |
SVC_HANDLER * | svc_handlers[], | |||
ACE_PEER_CONNECTOR_ADDR | remote_addrs[], | |||
ACE_TCHAR * | failed_svc_handlers = 0 , |
|||
const ACE_Synch_Options & | synch_options = ACE_Synch_Options::defaults | |||
) | [virtual] |
Initiate connection of n svc_handlers to peers at remote_addrs using synch_options. Returns -1 if failure occurs and 0 otherwise. If failed_svc_handlers is non-NULL, a 1 is placed in the corresponding index of failed_svc_handlers for each <svc_handlers[i]> that failed to connect, else a 0 is placed in that index.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connect_svc_handler | ( | SVC_HANDLER *& | svc_handler, | |
SVC_HANDLER *& | sh_copy, | |||
const ACE_PEER_CONNECTOR_ADDR & | remote_addr, | |||
ACE_Time_Value * | timeout, | |||
const ACE_PEER_CONNECTOR_ADDR & | local_addr, | |||
int | reuse_addr, | |||
int | flags, | |||
int | perms | |||
) | [protected, virtual] |
Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connect_svc_handler | ( | SVC_HANDLER *& | svc_handler, | |
const ACE_PEER_CONNECTOR_ADDR & | remote_addr, | |||
ACE_Time_Value * | timeout, | |||
const ACE_PEER_CONNECTOR_ADDR & | local_addr, | |||
int | reuse_addr, | |||
int | flags, | |||
int | perms | |||
) | [protected, virtual] |
Bridge method for connecting the svc_handler to the remote_addr. The default behavior delegates to the <PEER_CONNECTOR::connect>.
Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >.
virtual ACE_PEER_CONNECTOR& ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connector | ( | void | ) | const [virtual] |
Return the underlying PEER_CONNECTOR object.
void ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::dump | ( | void | ) | const |
Dump the state of an object.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::fini | ( | void | ) | [protected, virtual] |
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::info | ( | ACE_TCHAR ** | strp, | |
size_t | length | |||
) | const [protected, virtual] |
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::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.
virtual void ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::initialize_svc_handler | ( | ACE_HANDLE | handle, | |
SVC_HANDLER * | svc_handler | |||
) | [virtual] |
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::make_svc_handler | ( | SVC_HANDLER *& | sh | ) | [protected, virtual] |
Bridge method for creating a SVC_HANDLER. The default is to create a new SVC_HANDLER only 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 if failure, else 0.
Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >.
ACE_Unbounded_Set<ACE_HANDLE>& ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::non_blocking_handles | ( | void | ) | [protected, virtual] |
Return the handle set representing the non-blocking connects in progress.
Implements ACE_Connector_Base< SVC_HANDLER >.
int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::nonblocking_connect | ( | SVC_HANDLER * | , | |
const ACE_Synch_Options & | ||||
) | [protected] |
Creates and registers ACE_NonBlocking_Connect_Handler.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::open | ( | ACE_Reactor * | r = ACE_Reactor::instance() , |
|
int | flags = 0 | |||
) | [virtual] |
Initialize a connector. 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.
Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >.
virtual ACE_Reactor* ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::reactor | ( | void | ) | const [virtual] |
virtual void ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::reactor | ( | ACE_Reactor * | reactor | ) | [virtual] |
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::resume | ( | void | ) | [protected, virtual] |
Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.
Reimplemented from ACE_Service_Object.
virtual int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::suspend | ( | void | ) | [protected, virtual] |
Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.
Reimplemented from ACE_Service_Object.
ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
ACE_PEER_CONNECTOR ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::connector_ [private] |
This is the peer connector factory.
int ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::flags_ [private] |
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.
ACE_Unbounded_Set<ACE_HANDLE> ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::non_blocking_handles_ [private] |
Handle set representing the non-blocking connects in progress.
ACE_Reactor* ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_1 >::reactor_ [private] |