00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file UPIPE_Connector.h 00006 * 00007 * $Id: UPIPE_Connector.h 69062 2005-10-28 23:55:10Z ossama $ 00008 * 00009 * @author Gerhard Lenzer and Douglas C. Schmidt 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef ACE_UPIPE_CONNECTOR_H 00015 #define ACE_UPIPE_CONNECTOR_H 00016 #include /**/ "ace/pre.h" 00017 00018 #include "ace/UPIPE_Stream.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #if defined (ACE_HAS_THREADS) 00025 00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 /** 00029 * @class ACE_UPIPE_Connector 00030 * 00031 * @brief Defines an active connection factory for the 00032 * ACE_UPIPE_STREAM wrappers. 00033 */ 00034 class ACE_Export ACE_UPIPE_Connector 00035 { 00036 public: 00037 // = Initialization methods. 00038 /// Default constructor. 00039 ACE_UPIPE_Connector (void); 00040 00041 /** 00042 * Actively connect and produce a @a new_stream if things go well. 00043 * The @a addr is the address that we are trying to connect 00044 * with. The @a timeout is the amount of time to wait to connect. 00045 * If it's 0 then we block indefinitely. If *timeout == {0, 0} then 00046 * the connection is done using non-blocking mode. In this case, if 00047 * the connection can't be made immediately the value of -1 is 00048 * returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then 00049 * this is the maximum amount of time to wait before timing out. If the 00050 * time expires before the connection is made <errno == ETIME>. The 00051 * @a local_sap is the value of local address to bind to. If it's 00052 * the default value of ACE_Addr::sap_any then the user is letting 00053 * the OS do the binding. If @a reuse_addr == 1 then the 00054 * @a local_addr is reused, even if it hasn't been cleanedup yet. 00055 * The @a flags and @a perms arguments are passed down to the open() 00056 * method. 00057 */ 00058 ACE_UPIPE_Connector (ACE_UPIPE_Stream &new_stream, 00059 const ACE_UPIPE_Addr &addr, 00060 ACE_Time_Value *timeout = 0, 00061 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00062 int reuse_addr = 0, 00063 int flags = O_RDWR, 00064 int perms = 0); 00065 00066 /** 00067 * Actively connect and produce a @a new_stream if things go well. 00068 * The @a addr is the address that we are trying to connect 00069 * with. The @a timeout is the amount of time to wait to connect. 00070 * If it's 0 then we block indefinitely. If *timeout == {0, 0} then 00071 * the connection is done using non-blocking mode. In this case, if 00072 * the connection can't be made immediately the value of -1 is 00073 * returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then 00074 * this is the maximum amount of time to wait before timing out. If the 00075 * time expires before the connection is made <errno == ETIME>. The 00076 * @a local_sap is the value of local address to bind to. If it's 00077 * the default value of ACE_Addr::sap_any then the user is letting 00078 * the OS do the binding. If @a reuse_addr == 1 then the 00079 * @a local_addr is reused, even if it hasn't been cleanedup yet. 00080 * The @a flags and @a perms arguments are passed down to the open() 00081 * method. 00082 */ 00083 int connect (ACE_UPIPE_Stream &new_stream, 00084 const ACE_UPIPE_Addr &addr, 00085 ACE_Time_Value *timeout = 0, 00086 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00087 int reuse_addr = 0, 00088 int flags = O_RDWR, 00089 int perms = 0); 00090 00091 /// Resets any event associations on this handle 00092 int reset_new_handle (ACE_HANDLE handle); 00093 00094 // = Meta-type info 00095 typedef ACE_UPIPE_Addr PEER_ADDR; 00096 typedef ACE_UPIPE_Stream PEER_STREAM; 00097 00098 /// Dump the state of an object. 00099 void dump (void) const; 00100 00101 /// Declare the dynamic allocation hooks. 00102 ACE_ALLOC_HOOK_DECLARE; 00103 }; 00104 00105 ACE_END_VERSIONED_NAMESPACE_DECL 00106 00107 #if defined (__ACE_INLINE__) 00108 #include "ace/UPIPE_Connector.inl" 00109 #endif /* __ACE_INLINE__ */ 00110 00111 #endif /* ACE_HAS_THREADS */ 00112 00113 #include /**/ "ace/post.h" 00114 00115 #endif /* ACE_UPIPE_CONNECTOR_H */