00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file TLI_Connector.h 00006 * 00007 * TLI_Connector.h,v 4.18 2005/10/28 16:14:56 ossama Exp 00008 * 00009 * @author Doug Schmidt 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef ACE_TLI_CONNECTOR_H 00015 #define ACE_TLI_CONNECTOR_H 00016 #include /**/ "ace/pre.h" 00017 00018 #include "ace/TLI_Stream.h" 00019 #include "ace/Log_Msg.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 # pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 #if defined (ACE_HAS_TLI) 00026 00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00028 00029 /** 00030 * @class ACE_TLI_Connector 00031 * 00032 * @brief Defines an active connection factory for the ACE_TLI C++ 00033 * wrappers. 00034 */ 00035 class ACE_Export ACE_TLI_Connector 00036 { 00037 public: 00038 // = Initialization methods. 00039 /// Default constructor. 00040 ACE_TLI_Connector (void); 00041 00042 /** 00043 * Actively connect and produce a <new_stream> if things go well. 00044 * The <remote_sap> is the address that we are trying to connect 00045 * with. The <timeout> is the amount of time to wait to connect. 00046 * If it's 0 then we block indefinitely. If *timeout == {0, 0} then 00047 * the connection is done using non-blocking mode. In this case, if 00048 * the connection can't be made immediately the value of -1 is 00049 * returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then 00050 * this is the maximum amount of time to wait before timing out. If the 00051 * time expires before the connection is made <errno == ETIME>. The 00052 * <local_sap> is the value of local address to bind to. If it's 00053 * the default value of <ACE_Addr::sap_any> then the user is letting 00054 * the OS do the binding. If <reuse_addr> == 1 then the 00055 * <local_addr> is reused, even if it hasn't been cleanedup yet. 00056 */ 00057 ACE_TLI_Connector (ACE_TLI_Stream &new_stream, 00058 const ACE_Addr &remote_sap, 00059 ACE_Time_Value *timeout = 0, 00060 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00061 int reuse_addr = 0, 00062 int flags = O_RDWR, 00063 int perms = 0, 00064 const char device[] = ACE_TLI_TCP_DEVICE, 00065 struct t_info *info = 0, 00066 int rw_flag = 1, 00067 struct netbuf *udata = 0, 00068 struct netbuf *opt = 0); 00069 00070 /** 00071 * Actively connect and produce a <new_stream> if things go well. 00072 * The <remote_sap> is the address that we are trying to connect 00073 * with. The <timeout> is the amount of time to wait to connect. 00074 * If it's 0 then we block indefinitely. If *timeout == {0, 0} then 00075 * the connection is done using non-blocking mode. In this case, if 00076 * the connection can't be made immediately the value of -1 is 00077 * returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then 00078 * this is the maximum amount of time to wait before timing out. If the 00079 * time expires before the connection is made <errno == ETIME>. The 00080 * <local_sap> is the value of local address to bind to. If it's 00081 * the default value of <ACE_Addr::sap_any> then the user is letting 00082 * the OS do the binding. If <reuse_addr> == 1 then the 00083 * <local_addr> is reused, even if it hasn't been cleanedup yet. 00084 */ 00085 int connect (ACE_TLI_Stream &new_stream, 00086 const ACE_Addr &remote_sap, 00087 ACE_Time_Value *timeout = 0, 00088 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00089 int reuse_addr = 0, 00090 int flags = O_RDWR, 00091 int perms = 0, 00092 const char device[] = ACE_TLI_TCP_DEVICE, 00093 struct t_info *info = 0, 00094 int rw_flag = 1, 00095 struct netbuf *udata = 0, 00096 struct netbuf *opt = 0); 00097 00098 /** 00099 * Try to complete a non-blocking connection. 00100 * If connection completion is successful then <new_stream> contains 00101 * the connected ACE_SOCK_Stream. If <remote_sap> is non-NULL then it 00102 * will contain the address of the connected peer. 00103 */ 00104 int complete (ACE_TLI_Stream &new_stream, 00105 ACE_Addr *remote_sap, 00106 ACE_Time_Value *tv); 00107 00108 /// Resets any event associations on this handle 00109 int reset_new_handle (ACE_HANDLE handle); 00110 00111 // = Meta-type info 00112 typedef ACE_INET_Addr PEER_ADDR; 00113 typedef ACE_TLI_Stream PEER_STREAM; 00114 00115 /// Dump the state of an object. 00116 void dump (void) const; 00117 00118 /// Declare the dynamic allocation hooks. 00119 ACE_ALLOC_HOOK_DECLARE; 00120 }; 00121 00122 ACE_END_VERSIONED_NAMESPACE_DECL 00123 00124 #if defined (__ACE_INLINE__) 00125 #include "ace/TLI_Connector.inl" 00126 #endif /* __ACE_INLINE__ */ 00127 00128 #endif /* ACE_HAS_TLI */ 00129 #include /**/ "ace/post.h" 00130 #endif /* ACE_TLI_CONNECTOR_H */