00001 /* -*- C++ -*- */ 00002 00003 //============================================================================= 00004 /** 00005 * @file FILE_Connector.h 00006 * 00007 * FILE_Connector.h,v 4.26 2005/10/28 16:14:52 ossama Exp 00008 * 00009 * @author Doug Schmidt <schmidt@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_FILE_CONNECTOR_H 00014 #define ACE_FILE_CONNECTOR_H 00015 #include /**/ "ace/pre.h" 00016 00017 #include "ace/FILE_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 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 /** 00028 * @class ACE_FILE_Connector 00029 * 00030 * @brief Defines an active connection factory for the ACE_FILE wrappers. 00031 * 00032 * Note that the O_APPEND flag is only partly supported on Win32. If 00033 * you specify O_APPEND, then the file pointer will be positioned at 00034 * the end of the file initially during open, but it is not 00035 * re-positioned at the end prior to each write, as specified by 00036 * POSIX. This is generally good enough for typical situations, but 00037 * it is ``not quite right'' in its semantics. 00038 */ 00039 class ACE_Export ACE_FILE_Connector 00040 { 00041 public: 00042 // = Initialization methods. 00043 /// Default constructor. 00044 ACE_FILE_Connector (void); 00045 00046 /** 00047 * Actively ``connect'' and produce a <new_io> <ACE_FILE_IO> object 00048 * if things go well. The <remote_sap> is the file that we are 00049 * trying to create/open. If it's the default value of 00050 * <ACE_Addr::sap_any> then the user is letting the OS create the 00051 * filename (via <ACE_OS::mktemp>). The <timeout> is the amount of 00052 * time to wait to create/open the file. If it's 0 then we block 00053 * indefinitely. If *timeout == {0, 0} then the file is created 00054 * using non-blocking mode. In this case, if the create/open can't 00055 * be done immediately the value of -1 is returned with <errno == 00056 * EWOULDBLOCK>. If *timeout > {0, 0} then this is the maximum amount of 00057 * time to wait before timing out. If the time expires before the 00058 * connection is made <errno == ETIME>. The <local_sap> and 00059 * <reuse_addr> parameters are ignored. The <flags> and <perms> 00060 * arguments are passed down to the <ACE_OS::open> method. 00061 */ 00062 ACE_FILE_Connector (ACE_FILE_IO &new_io, 00063 const ACE_FILE_Addr &remote_sap, 00064 ACE_Time_Value *timeout = 0, 00065 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00066 int reuse_addr = 0, 00067 int flags = O_RDWR | O_CREAT, 00068 int perms = ACE_DEFAULT_FILE_PERMS); 00069 00070 /** 00071 * Actively ``connect'' and produce a <new_io> <ACE_FILE_IO> object 00072 * if things go well. The <remote_sap> is the file that we are 00073 * trying to create/open. If it's the default value of 00074 * <ACE_Addr::sap_any> then the user is letting the OS create the 00075 * filename (via <ACE_OS::mktemp>). The <timeout> is the amount of 00076 * time to wait to create/open the file. If it's 0 then we block 00077 * indefinitely. If *timeout == {0, 0} then the file is created 00078 * using non-blocking mode. In this case, if the create/open can't 00079 * be done immediately the value of -1 is returned with <errno == 00080 * EWOULDBLOCK>. If *timeout > {0, 0} then this is the maximum amount of 00081 * time to wait before timing out. If the time expires before the 00082 * connection is made <errno == ETIME>. The <local_sap> and 00083 * <reuse_addr> parameters are ignored. The <flags> and <perms> 00084 * arguments are passed down to the <ACE_OS::open> method. 00085 */ 00086 int connect (ACE_FILE_IO &new_io, 00087 const ACE_FILE_Addr &remote_sap, 00088 ACE_Time_Value *timeout = 0, 00089 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00090 int reuse_addr = 0, 00091 int flags = O_RDWR | O_CREAT, 00092 int perms = ACE_DEFAULT_FILE_PERMS); 00093 00094 /// Resets any event associations on this handle 00095 int reset_new_handle (ACE_HANDLE handle); 00096 00097 /// Dump the state of an object. 00098 void dump (void) const; 00099 00100 /// Declare the dynamic allocation hooks. 00101 ACE_ALLOC_HOOK_DECLARE; 00102 00103 // = Meta-type "trait" information. 00104 typedef ACE_FILE_Addr PEER_ADDR; 00105 typedef ACE_FILE_IO PEER_STREAM; 00106 }; 00107 00108 ACE_END_VERSIONED_NAMESPACE_DECL 00109 00110 #if defined (__ACE_INLINE__) 00111 #include "ace/FILE_Connector.inl" 00112 #endif /* __ACE_INLINE__ */ 00113 00114 #include /**/ "ace/post.h" 00115 #endif /* ACE_FILE_CONNECTOR_H */