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