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

ACE_MEM_Connector Class Reference

Defines the format and interface for connecting to a peer on a ACE_MEM_Stream object. More...

#include <MEM_Connector.h>

Inheritance diagram for ACE_MEM_Connector:

Inheritance graph
[legend]
Collaboration diagram for ACE_MEM_Connector:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_INET_Addr PEER_ADDR
typedef ACE_MEM_Stream PEER_STREAM

Public Methods

 ACE_MEM_Connector (void)
 Default constructor. More...

 ACE_MEM_Connector (ACE_MEM_Stream &new_stream, const ACE_INET_Addr &remote_sap, ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=0, int perms=0)
int connect (ACE_MEM_Stream &new_stream, const ACE_INET_Addr &remote_sap, ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=0, int perms=0)
ACE_MEM_IO::Signal_Strategy preferred_strategy (void) const
 Get the preferred signaling strategy. More...

void preferred_strategy (ACE_MEM_IO::Signal_Strategy strategy)
 Set the preferred signaling strategy. More...

ACE_MEM_SAP::MALLOC_OPTIONSmalloc_options (void)
 Accessor to underlying malloc options. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Attributes

ACE_MEM_Addr address_
 The acceptor address this connector is connecting to. More...

ACE_MEM_SAP::MALLOC_OPTIONS malloc_options_
 A cached MALLOC_OPTIONS that the MEM_Connector used to initialize the shared memory malloc update connection establishment. More...

ACE_MEM_IO::Signal_Strategy preferred_strategy_
 Preferred signaling strategy. More...


Detailed Description

Defines the format and interface for connecting to a peer on a ACE_MEM_Stream object.

Definition at line 34 of file MEM_Connector.h.


Member Typedef Documentation

typedef ACE_INET_Addr ACE_MEM_Connector::PEER_ADDR
 

Reimplemented from ACE_SOCK_Connector.

Definition at line 145 of file MEM_Connector.h.

typedef ACE_MEM_Stream ACE_MEM_Connector::PEER_STREAM
 

Reimplemented from ACE_SOCK_Connector.

Definition at line 146 of file MEM_Connector.h.


Constructor & Destructor Documentation

ACE_MEM_Connector::ACE_MEM_Connector void   
 

Default constructor.

Definition at line 27 of file MEM_Connector.cpp.

References ACE_DEFAULT_BASE_ADDR, and ACE_TRACE.

00028   : malloc_options_ (ACE_DEFAULT_BASE_ADDR, 0),
00029     preferred_strategy_ (ACE_MEM_IO::Reactive)
00030 {
00031   ACE_TRACE ("ACE_MEM_Connector::ACE_MEM_Connector");
00032 }

ACE_MEM_Connector::ACE_MEM_Connector ACE_MEM_Stream   new_stream,
const ACE_INET_Addr   remote_sap,
ACE_Time_Value   timeout = 0,
const ACE_Addr   local_sap = ACE_Addr::sap_any,
int    reuse_addr = 0,
int    flags = 0,
int    perms = 0
 

Actively connect to a peer, producing a connected ACE_MEM_Stream object if the connection succeeds.

Parameters:
new_stream  The ACE_MEM_Stream object that will be connected to the peer.
remote_sap  The address that we are trying to connect to. The protocol family of remote_sap is used for the connected socket. That is, if remote_sap contains an IPv6 address, a socket with family PF_INET6 will be used, else it will be PF_INET.
Note:
remote_sap must be an address on the local host.
Parameters:
timeout  Pointer to an ACE_Time_Value object with amount of time to wait to connect. If the pointer is 0 then the call blocks until the connection attempt is complete, whether it succeeds or fails. If *timeout == {0, 0} then the connection is done using nonblocking mode. In this case, if the connection can't be made immediately, this method returns -1 and errno == EWOULDBLOCK. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out; if the specified amount of time passes before the connection is made, this method returns -1 and errno == ETIME. Note the difference between this case and when a blocking connect is attmpted that TCP times out - in the latter case, errno will be ETIMEDOUT.
local_sap  (optional) The local address to bind to. If it's the default value of ACE_Addr::sap_any then the OS will choose an unused port.
reuse_addr  (optional) If the value is 1, the local address (local_sap) is reused, even if it hasn't been cleaned up yet.
flags  Ignored.
perms  Ignored.

Definition at line 35 of file MEM_Connector.cpp.

References ACE_DEFAULT_BASE_ADDR, ACE_TRACE, and connect.

00042   : malloc_options_ (ACE_DEFAULT_BASE_ADDR, 0),
00043     preferred_strategy_ (ACE_MEM_IO::Reactive)
00044 {
00045   ACE_TRACE ("ACE_MEM_Connector::ACE_MEM_Connector");
00046   // This is necessary due to the weird inheritance relationships of
00047   // ACE_MEM_Stream.
00048   this->connect (new_stream,
00049                  remote_sap,
00050                  timeout,
00051                  local_sap,
00052                  reuse_addr,
00053                  flags,
00054                  perms);
00055 }


Member Function Documentation

int ACE_MEM_Connector::connect ACE_MEM_Stream   new_stream,
const ACE_INET_Addr   remote_sap,
ACE_Time_Value   timeout = 0,
const ACE_Addr   local_sap = ACE_Addr::sap_any,
int    reuse_addr = 0,
int    flags = 0,
int    perms = 0
 

Actively connect to a peer, producing a connected ACE_MEM_Stream object if the connection succeeds.

Parameters:
new_stream  The ACE_MEM_Stream object that will be connected to the peer.
remote_sap  The address that we are trying to connect to. The protocol family of remote_sap is used for the connected socket. That is, if remote_sap contains an IPv6 address, a socket with family PF_INET6 will be used, else it will be PF_INET.
Note:
remote_sap must be an address on the local host.
Parameters:
timeout  Pointer to an ACE_Time_Value object with amount of time to wait to connect. If the pointer is 0 then the call blocks until the connection attempt is complete, whether it succeeds or fails. If *timeout == {0, 0} then the connection is done using nonblocking mode. In this case, if the connection can't be made immediately, this method returns -1 and errno == EWOULDBLOCK. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out; if the specified amount of time passes before the connection is made, this method returns -1 and errno == ETIME. Note the difference between this case and when a blocking connect is attmpted that TCP times out - in the latter case, errno will be ETIMEDOUT.
local_sap  (optional) The local address to bind to. If it's the default value of ACE_Addr::sap_any then the OS will choose an unused port.
reuse_addr  (optional) If the value is 1, the local address (local_sap) is reused, even if it hasn't been cleaned up yet.
flags  Ignored.
perms  Ignored.
Returns:
Returns 0 if the connection succeeds. If it fails, -1 is returned and errno contains a specific error code.

Definition at line 58 of file MEM_Connector.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_NONBLOCK, ACE_TCHAR, ACE_TRACE, address_, ACE_SOCK_Connector::connect, ACE_IPC_SAP::disable, ACE_IPC_SAP::get_handle, ACE_MEM_Addr::get_host_name, ACE_INET_Addr::get_host_name, ACE_SOCK::get_local_addr, ACE_MEM_Addr::get_port_number, ACE_INET_Addr::get_port_number, ACE_MEM_IO::init, LM_DEBUG, LM_ERROR, MAXPATHLEN, ACE_MEM_IO::MT, preferred_strategy_, ACE_MEM_IO::Reactive, ACE::recv, ACE_MEM_Addr::same_host, ACE::send, ACE_IPC_SAP::set_handle, ACE_MEM_Addr::set_port_number, and ACE_MEM_IO::Signal_Strategy.

Referenced by ACE_MEM_Connector.

00065 {
00066   ACE_TRACE ("ACE_MEM_Connector::connect");
00067 
00068   if (!this->address_.same_host (remote_sap))
00069     ACE_ERROR_RETURN ((LM_ERROR,
00070                        ACE_LIB_TEXT ("(%P|%t) MEM_Connector can't connect ")
00071                        ACE_LIB_TEXT ("to %s:%d which is not a local endpoint ")
00072                        ACE_LIB_TEXT ("(local address is %s:%d)\n"),
00073                        remote_sap.get_host_name (),
00074                        remote_sap.get_port_number (),
00075                        this->address_.get_host_name (),
00076                        this->address_.get_port_number ()),
00077                       -1);
00078   else
00079     this->address_.set_port_number (remote_sap.get_port_number ());
00080 
00081 
00082   ACE_SOCK_Stream temp_stream;
00083 
00084   if (ACE_SOCK_Connector::connect (temp_stream,
00085                                    this->address_.get_local_addr (),
00086                                    timeout, local_sap,
00087                                    reuse_addr, flags, perms) == -1)
00088     ACE_ERROR_RETURN ((LM_DEBUG,
00089                        ACE_LIB_TEXT ("%p\n"),
00090                        ACE_LIB_TEXT ("ACE_MEM_Connector::connect")),
00091                       -1);
00092 
00093 
00094   ACE_HANDLE new_handle = temp_stream.get_handle ();
00095   new_stream.set_handle (new_handle);
00096   new_stream.disable (ACE_NONBLOCK);
00097   // Do not close the handle.
00098 
00099   // now we should setup the mmap malloc.
00100   ACE_TCHAR buf[MAXPATHLEN];
00101 
00102   // @@ Need to handle timeout here.
00103   ACE_INT16 server_strategy = ACE_MEM_IO::Reactive;
00104   // Receive the signaling strategy theserver support.
00105   if (ACE::recv (new_handle, &server_strategy,
00106                  sizeof (ACE_INT16)) == -1)
00107     ACE_ERROR_RETURN ((LM_DEBUG,
00108                        ACE_LIB_TEXT ("ACE_MEM_Connector::connect error receiving strategy\n")),
00109                       -1);
00110 
00111     // If either side don't support MT, we will not use it.
00112 #if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
00113   if (! (this->preferred_strategy_ == ACE_MEM_IO::MT &&
00114          server_strategy == ACE_MEM_IO::MT))
00115 #endif /* ACE_WIN32 || !_ACE_USE_SV_SEM */
00116     server_strategy = ACE_MEM_IO::Reactive;
00117 
00118   if (ACE::send (new_handle, &server_strategy,
00119                  sizeof (ACE_INT16)) == -1)
00120     ACE_ERROR_RETURN ((LM_DEBUG,
00121                        ACE_LIB_TEXT ("ACE_MEM_Connector::connect error sending strategy\n")),
00122                       -1);
00123 
00124   ACE_INT16 buf_len;
00125   // Byte-order is not a problem for this read.
00126   if (ACE::recv (new_handle, &buf_len, sizeof (buf_len)) == -1)
00127     ACE_ERROR_RETURN ((LM_DEBUG,
00128                        ACE_LIB_TEXT ("ACE_MEM_Connector::connect error receiving shm filename length\n")),
00129                       -1);
00130 
00131   if (ACE::recv (new_handle, buf, buf_len) == -1)
00132     ACE_ERROR_RETURN ((LM_DEBUG,
00133                        ACE_LIB_TEXT ("ACE_MEM_Connector::connect error receiving shm filename.\n")),
00134                       -1);
00135 
00136   if (new_stream.init (buf, ACE_static_cast (ACE_MEM_IO::Signal_Strategy, server_strategy),
00137                        &this->malloc_options_) == -1)
00138     return -1;
00139 
00140   return 0;
00141 }

void ACE_MEM_Connector::dump void    const
 

Dump the state of an object.

Reimplemented from ACE_SOCK_Connector.

Definition at line 18 of file MEM_Connector.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.

00019 {
00020   ACE_TRACE ("ACE_MEM_Connector::dump");
00021 
00022   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00023   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\n")));
00024   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00025 }

ASYS_INLINE ACE_MEM_SAP::MALLOC_OPTIONS & ACE_MEM_Connector::malloc_options void   
 

Accessor to underlying malloc options.

Definition at line 21 of file MEM_Connector.i.

References malloc_options_.

00022 {
00023   return this->malloc_options_;
00024 }

ASYS_INLINE void ACE_MEM_Connector::preferred_strategy ACE_MEM_IO::Signal_Strategy    strategy
 

Set the preferred signaling strategy.

Definition at line 15 of file MEM_Connector.i.

References preferred_strategy_, and ACE_MEM_IO::Signal_Strategy.

00016 {
00017   this->preferred_strategy_ = strategy;
00018 }

ASYS_INLINE ACE_MEM_IO::Signal_Strategy ACE_MEM_Connector::preferred_strategy void    const
 

Get the preferred signaling strategy.

Definition at line 9 of file MEM_Connector.i.

References preferred_strategy_.

00010 {
00011   return this->preferred_strategy_;
00012 }


Member Data Documentation

ACE_MEM_Connector::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_SOCK_Connector.

Definition at line 152 of file MEM_Connector.h.

ACE_MEM_Addr ACE_MEM_Connector::address_ [private]
 

The acceptor address this connector is connecting to.

Definition at line 156 of file MEM_Connector.h.

Referenced by connect.

ACE_MEM_SAP::MALLOC_OPTIONS ACE_MEM_Connector::malloc_options_ [private]
 

A cached MALLOC_OPTIONS that the MEM_Connector used to initialize the shared memory malloc update connection establishment.

Definition at line 160 of file MEM_Connector.h.

Referenced by malloc_options.

ACE_MEM_IO::Signal_Strategy ACE_MEM_Connector::preferred_strategy_ [private]
 

Preferred signaling strategy.

Definition at line 163 of file MEM_Connector.h.

Referenced by connect, and preferred_strategy.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:50:17 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002