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

ACE_ATM_Connector Class Reference

Defines an active connection factory for the ACE_ATM C++ wrappers. More...

#include <ATM_Connector.h>

Collaboration diagram for ACE_ATM_Connector:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_ATM_Addr PEER_ADDR
typedef ACE_ATM_Stream PEER_STREAM

Public Methods

 ACE_ATM_Connector (void)
 Default constructor. More...

 ACE_ATM_Connector (ACE_ATM_Stream &new_stream, const ACE_ATM_Addr &remote_sap, ACE_ATM_Params params=ACE_ATM_Params(), ACE_ATM_QoS options=ACE_ATM_QoS(), ACE_Time_Value *timeout=0, const ACE_ATM_Addr &local_sap=ACE_ATM_Addr("", 0), int reuse_addr=0, int flags=0, int perms=0)
int connect (ACE_ATM_Stream &new_stream, const ACE_ATM_Addr &remote_sap, ACE_ATM_Params params=ACE_ATM_Params(), ACE_ATM_QoS options=ACE_ATM_QoS(), ACE_Time_Value *timeout=0, const ACE_ATM_Addr &local_sap=ACE_ATM_Addr("", 0), int reuse_addr=0, int flags=0, int perms=0)
int complete (ACE_ATM_Stream &new_stream, ACE_ATM_Addr *remote_sap, ACE_Time_Value *tv)
int add_leaf (ACE_ATM_Stream &current_stream, const ACE_Addr &remote_sap, ACE_ATM_QoS &qos)
int reset_new_handle (ACE_HANDLE handle)
 Resets any event associations on this handle. 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

ATM_Connector connector_

Detailed Description

Defines an active connection factory for the ACE_ATM C++ wrappers.

Definition at line 43 of file ATM_Connector.h.


Member Typedef Documentation

typedef ACE_ATM_Addr ACE_ATM_Connector::PEER_ADDR
 

Definition at line 139 of file ATM_Connector.h.

typedef ACE_ATM_Stream ACE_ATM_Connector::PEER_STREAM
 

Definition at line 140 of file ATM_Connector.h.


Constructor & Destructor Documentation

ACE_ATM_Connector::ACE_ATM_Connector void   
 

Default constructor.

Definition at line 24 of file ATM_Connector.cpp.

References ACE_TRACE.

00025 {
00026   ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
00027 }

ACE_INLINE ACE_ATM_Connector::ACE_ATM_Connector ACE_ATM_Stream   new_stream,
const ACE_ATM_Addr   remote_sap,
ACE_ATM_Params    params = ACE_ATM_Params(),
ACE_ATM_QoS    options = ACE_ATM_QoS(),
ACE_Time_Value   timeout = 0,
const ACE_ATM_Addr   local_sap = ACE_ATM_Addr("", 0),
int    reuse_addr = 0,
int    flags = 0,
int    perms = 0
 

Actively connect and produce a <new_stream> if things go well. The <remote_sap> is the address that we are trying to connect with. The <params> are the parameters needed for either socket or XTI/ATM connections. The <timeout> is the amount of time to wait to connect. If it's 0 then we block indefinitely. If *timeout == {0, 0} then the connection is done using non-blocking mode. In this case, if the connection can't be made immediately the value of -1 is returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out. If the time expires before the connection is made <errno == ETIME>. The <local_sap> is the value of local address to bind to. If it's the default value of <ACE_ATM_Addr::sap_any> then the user is letting the OS do the binding. If <reuse_addr> == 1 then the <local_addr> is reused, even if it hasn't been cleanedup yet.

Definition at line 7 of file ATM_Connector.i.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, connect, ETIME, EWOULDBLOCK, and LM_ERROR.

00016 {
00017   ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
00018   if ((ACE_HANDLE)this->connect (new_stream,
00019                                  remote_sap,
00020                                  params,
00021                                  options,
00022                                  timeout,
00023                                  local_sap,
00024                                  reuse_addr, 
00025                                  flags,
00026                                  perms) == ACE_INVALID_HANDLE
00027       && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
00028     ACE_ERROR ((LM_ERROR,  ACE_LIB_TEXT ("%p\n"),  
00029                 ACE_LIB_TEXT ("ACE_ATM_Stream::ACE_ATM_Stream")));
00030 }


Member Function Documentation

ACE_INLINE int ACE_ATM_Connector::add_leaf ACE_ATM_Stream   current_stream,
const ACE_Addr   remote_sap,
ACE_ATM_QoS   qos
 

Actively add a leaf to the root (i.e., point-to-multipoint). The <remote_sap> is the address of the leaf that we are trying to add.

Definition at line 55 of file ATM_Connector.i.

References ACE_TRACE, connector_, ACE_ATM_Stream::get_handle, ACE_ATM_QoS::get_qos, ACE_ATM_Stream::get_stream, ACE_OS::join_leaf, and ACE_OS::printf.

00058 {
00059   ACE_TRACE ("ACE_ATM_Connector::add_leaf");
00060 #if defined (ACE_HAS_FORE_ATM_XTI)
00061   return connector_.add_leaf(current_stream.get_stream(),
00062                              remote_sap,
00063                              leaf_id,
00064                              timeout);
00065 #elif defined (ACE_HAS_FORE_ATM_WS2)
00066   struct sockaddr_atm *saddr = (struct sockaddr_atm *)remote_sap.get_addr();
00067   ACE_QoS cqos = qos.get_qos();
00068   int addr_len = sizeof( struct sockaddr_atm );
00069 
00070   ACE_QoS_Params qos_params(0,
00071                             0,
00072                             &cqos,
00073                             0,
00074                             (JL_SENDER_ONLY));
00075  
00076   ACE_OS::printf( "ATM_Connector::add_leaf: connecting...\n" );
00077 
00078   ACE_HANDLE result = ACE_OS::join_leaf(current_stream.get_handle(),
00079                                         (struct sockaddr *)saddr, 
00080                                         addr_len,
00081                                         qos_params);
00082   
00083   if ( result == ACE_INVALID_HANDLE ) 
00084     ACE_OS::printf( "ATM_Connector(add_leaf): connection failed, %d\n", 
00085                     ::WSAGetLastError());
00086   
00087   return (result != ACE_INVALID_HANDLE);
00088 #elif defined (ACE_HAS_LINUX_ATM)
00089   ACE_OS::printf("ATM_Connector(add_leaf): not yet implemented in Linux \n");
00090 
00091   ACE_UNUSED_ARG(current_stream);
00092   ACE_UNUSED_ARG(remote_sap);
00093   ACE_UNUSED_ARG(leaf_id);
00094   ACE_UNUSED_ARG(timeout);
00095 
00096   return 0;
00097 #else
00098   ACE_UNUSED_ARG(current_stream);
00099   ACE_UNUSED_ARG(remote_sap);
00100   ACE_UNUSED_ARG(leaf_id);
00101   ACE_UNUSED_ARG(timeout);
00102   return 0;
00103 #endif
00104 }

ACE_INLINE int ACE_ATM_Connector::complete ACE_ATM_Stream   new_stream,
ACE_ATM_Addr   remote_sap,
ACE_Time_Value   tv
 

Try to complete a non-blocking connection. If connection completion is successful then <new_stream> contains the connected ACE_SOCK_Stream. If <remote_sap> is non-NULL then it will contain the address of the connected peer.

Definition at line 36 of file ATM_Connector.i.

References ACE_TRACE, ACE_SOCK_Connector::complete, connector_, and ACE_ATM_Stream::get_stream.

00039 {
00040   ACE_TRACE ("ACE_ATM_Connector::complete");
00041 #if defined (ACE_HAS_ATM)
00042   return connector_.complete(new_stream.get_stream(),
00043                              remote_sap,
00044                              tv);
00045 #else
00046   ACE_UNUSED_ARG(new_stream);
00047   ACE_UNUSED_ARG(remote_sap);
00048   ACE_UNUSED_ARG(tv);
00049   return 0;
00050 #endif
00051 }

int ACE_ATM_Connector::connect ACE_ATM_Stream   new_stream,
const ACE_ATM_Addr   remote_sap,
ACE_ATM_Params    params = ACE_ATM_Params(),
ACE_ATM_QoS    options = ACE_ATM_QoS(),
ACE_Time_Value   timeout = 0,
const ACE_ATM_Addr   local_sap = ACE_ATM_Addr("", 0),
int    reuse_addr = 0,
int    flags = 0,
int    perms = 0
 

Actively connect and produce a <new_stream> if things go well. The <remote_sap> is the address that we are trying to connect with. The <params> are the parameters needed for either socket or XTI/ATM connections. The <timeout> is the amount of time to wait to connect. If it's 0 then we block indefinitely. If *timeout == {0, 0} then the connection is done using non-blocking mode. In this case, if the connection can't be made immediately the value of -1 is returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out. If the time expires before the connection is made <errno == ETIME>. The <local_sap> is the value of local address to bind to. If it's the default value of <ACE_ATM_Addr::sap_any> then the user is letting the OS do the binding. If <reuse_addr> == 1 then the <local_addr> is reused, even if it hasn't been cleanedup yet.

Definition at line 34 of file ATM_Connector.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_TRACE, ATM_Addr, ATM_QoS, ACE_OS::connect, ACE_SOCK_Connector::connect, connector_, ACE_ATM_Addr::get_addr, ACE_ATM_Params::get_device, ACE_ATM_Stream::get_handle, ACE_ATM_Params::get_info, ACE_ATM_QoS::get_qos, ACE_ATM_Params::get_rw_flag, ACE_ATM_Stream::get_stream, ACE_ATM_Params::get_user_data, LM_DEBUG, ACE_OS::printf, and ACE_OS::setsockopt.

Referenced by ACE_ATM_Connector.

00043 {
00044   ACE_TRACE ("ACE_ATM_Connector::connect");
00045 #if defined (ACE_HAS_FORE_ATM_XTI)
00046   return connector_.connect(new_stream.get_stream(),
00047                             remote_sap,
00048                             timeout,
00049                             local_sap,
00050                             reuse_addr,
00051                             flags,
00052                             perms,
00053                             params.get_device(),
00054                             params.get_info(),
00055                             params.get_rw_flag(),
00056                             params.get_user_data(),
00057                             &options.get_qos());
00058 #elif defined (ACE_HAS_FORE_ATM_WS2)
00059   ACE_DEBUG(LM_DEBUG,
00060             ACE_LIB_TEXT ("ATM_Connector(connect): set QoS parameters\n" ));
00061 
00062   ACE_HANDLE s = new_stream.get_handle();
00063   struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr();
00064   ACE_QoS cqos = options.get_qos();
00065 
00066   ACE_QoS_Params qos_params = ACE_QoS_Params(0,
00067                                              0,
00068                                              &cqos,
00069                                              0,
00070                                              0);
00071 
00072   ACE_DEBUG(LM_DEBUG,
00073             ACE_LIB_TEXT ("ATM_Connector(connect): connecting...\n"));
00074 
00075   int result = ACE_OS::connect( s, 
00076                                 ( struct sockaddr *)saddr, 
00077                                 sizeof( struct sockaddr_atm ), 
00078                                 qos_params );
00079   
00080   if ( result != 0 ) 
00081     ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n", 
00082                     ::WSAGetLastError());
00083   
00084   return result;
00085 #elif defined (ACE_HAS_LINUX_ATM)
00086   ACE_UNUSED_ARG (params);
00087   ACE_UNUSED_ARG (timeout);
00088   ACE_UNUSED_ARG (reuse_addr);
00089   ACE_UNUSED_ARG (perms);
00090   ACE_UNUSED_ARG (flags);
00091 
00092   ACE_HANDLE handle = new_stream.get_handle();
00093   ATM_QoS qos =options.get_qos();
00094   ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(),
00095     *remote_addr=(ATM_Addr*)remote_sap.get_addr();
00096 
00097   if (ACE_OS::setsockopt(handle,
00098                          SOL_ATM,
00099                          SO_ATMSAP,
00100                          ACE_reinterpret_cast(char*,
00101                                               &(local_addr->atmsap)),
00102                          sizeof(local_addr->atmsap)) < 0) {
00103     ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...",
00104                     errno);
00105   }
00106   if (ACE_OS::setsockopt(handle,
00107                          SOL_ATM,
00108                          SO_ATMQOS,
00109                          ACE_reinterpret_cast(char*,
00110                                               &qos),
00111                          sizeof(qos)) < 0) {
00112     ACE_DEBUG((LM_DEBUG,ACE_LIB_TEXT ("ATM_Connector(connect): unable to set qos %d\n"),
00113                errno));
00114     return -1;
00115   }
00116 
00117   int result = ACE_OS::connect(handle,
00118                                (struct sockaddr *)&(remote_addr->sockaddratmsvc), 
00119                                sizeof( remote_addr->sockaddratmsvc));
00120   
00121   if ( result != 0 )
00122     ACE_DEBUG(LM_DEBUG,
00123               ACE_LIB_TEXT ("ATM_Connector(connect): connection failed, %d\n"),
00124               errno);
00125 
00126   return result;
00127 #else
00128   ACE_UNUSED_ARG (new_stream);
00129   ACE_UNUSED_ARG (remote_sap);
00130   ACE_UNUSED_ARG (params);
00131   ACE_UNUSED_ARG (options);
00132   ACE_UNUSED_ARG (timeout);
00133   ACE_UNUSED_ARG (local_sap);
00134   ACE_UNUSED_ARG (reuse_addr);
00135   ACE_UNUSED_ARG (flags);
00136   ACE_UNUSED_ARG (perms);
00137   return 0;
00138 #endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
00139 }

void ACE_ATM_Connector::dump void    const
 

Dump the state of an object.

Definition at line 19 of file ATM_Connector.cpp.

References ACE_TRACE.

00020 {
00021   ACE_TRACE ("ACE_ATM_Connector::dump");
00022 }

ACE_INLINE int ACE_ATM_Connector::reset_new_handle ACE_HANDLE    handle
 

Resets any event associations on this handle.

Definition at line 108 of file ATM_Connector.i.

References WSAEventSelect.

00109 {
00110 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00111   // Reset the event association 
00112   return ::WSAEventSelect ((SOCKET) handle,
00113                            0,
00114                            0);    
00115 #else /* !defined ACE_HAS_WINSOCK2 */
00116   ACE_UNUSED_ARG (handle);
00117   return 0;
00118 #endif /* ACE_WIN32 */
00119 }


Member Data Documentation

ACE_ATM_Connector::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 146 of file ATM_Connector.h.

ATM_Connector ACE_ATM_Connector::connector_ [private]
 

Definition at line 149 of file ATM_Connector.h.

Referenced by add_leaf, complete, and connect.


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