#include <FILE_Connector.h>
Public Types | |
typedef ACE_FILE_Addr | PEER_ADDR |
typedef ACE_FILE_IO | PEER_STREAM |
Public Member Functions | |
ACE_FILE_Connector (void) | |
Default constructor. | |
ACE_FILE_Connector (ACE_FILE_IO &new_io, const ACE_FILE_Addr &remote_sap, ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=O_RDWR|O_CREAT, int perms=ACE_DEFAULT_FILE_PERMS) | |
int | connect (ACE_FILE_IO &new_io, const ACE_FILE_Addr &remote_sap, ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=O_RDWR|O_CREAT, int perms=ACE_DEFAULT_FILE_PERMS) |
int | reset_new_handle (ACE_HANDLE handle) |
Resets any event associations on this handle. | |
void | dump (void) const |
Dump the state of an object. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. |
Note that the O_APPEND flag is only partly supported on Win32. If you specify O_APPEND, then the file pointer will be positioned at the end of the file initially during open, but it is not re-positioned at the end prior to each write, as specified by POSIX. This is generally good enough for typical situations, but it is ``not quite right'' in its semantics.
Definition at line 39 of file FILE_Connector.h.
Definition at line 102 of file FILE_Connector.h.
Definition at line 103 of file FILE_Connector.h.
ACE_FILE_Connector::ACE_FILE_Connector | ( | void | ) |
Default constructor.
Definition at line 29 of file FILE_Connector.cpp.
References ACE_TRACE.
00030 { 00031 ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector"); 00032 }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_FILE_Connector::ACE_FILE_Connector | ( | ACE_FILE_IO & | new_io, | |
const ACE_FILE_Addr & | remote_sap, | |||
ACE_Time_Value * | timeout = 0 , |
|||
const ACE_Addr & | local_sap = ACE_Addr::sap_any , |
|||
int | reuse_addr = 0 , |
|||
int | flags = O_RDWR|O_CREAT , |
|||
int | perms = ACE_DEFAULT_FILE_PERMS | |||
) |
Actively ``connect'' and produce a new_io ACE_FILE_IO object if things go well. The remote_sap is the file that we are trying to create/open. If it's the default value of ACE_Addr::sap_any then the user is letting the OS create the filename (via <ACE_OS::mkstemp>). The timeout is the amount of time to wait to create/open the file. If it's 0 then we block indefinitely. If *timeout == {0, 0} then the file is created using non-blocking mode. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out. The local_sap and reuse_addr parameters are ignored. The flags and perms arguments are passed down to the <ACE_OS::open> method.
Definition at line 10 of file FILE_Connector.inl.
References ACE_ERROR, ACE_TEXT, ACE_TRACE, ACE_FILE_Addr::get_path_name(), ACE_IO_SAP::INVALID_HANDLE, and LM_ERROR.
00017 { 00018 ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector"); 00019 if (this->connect (new_io, remote_sap, timeout, local_sap, 00020 reuse_addr, flags, perms) == ACE_IO_SAP::INVALID_HANDLE 00021 && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) 00022 ACE_ERROR ((LM_ERROR, 00023 ACE_TEXT ("address %s, %p\n"), 00024 remote_sap.get_path_name (), 00025 ACE_TEXT ("ACE_FILE_IO"))); 00026 }
int ACE_FILE_Connector::connect | ( | ACE_FILE_IO & | new_io, | |
const ACE_FILE_Addr & | remote_sap, | |||
ACE_Time_Value * | timeout = 0 , |
|||
const ACE_Addr & | local_sap = ACE_Addr::sap_any , |
|||
int | reuse_addr = 0 , |
|||
int | flags = O_RDWR|O_CREAT , |
|||
int | perms = ACE_DEFAULT_FILE_PERMS | |||
) |
Actively ``connect'' and produce a new_io <ACE_FILE_IO> object if things go well. The remote_sap is the file that we are trying to create/open. If it's the default value of ACE_Addr::sap_any then the user is letting the OS create the filename (via <ACE_OS::mkstemp>). The timeout is the amount of time to wait to create/open the file. If it's 0 then we block indefinitely. If *timeout == {0, 0} then the file is created using non-blocking mode. In this case, if the create/open can't be done 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 and reuse_addr parameters are ignored. The flags and perms arguments are passed down to the <ACE_OS::open> method.
Definition at line 35 of file FILE_Connector.cpp.
References ACE_ASSERT, ACE_TEXT_CHAR_TO_TCHAR, ACE_TRACE, ACE_FILE::addr_, ACE_IO_SAP::get_handle(), ACE_FILE_Addr::get_path_name(), ACE::handle_timed_open(), ACE_OS::mkstemp(), ACE_Addr::sap_any, ACE_FILE_Addr::set(), and ACE_IO_SAP::set_handle().
00042 { 00043 ACE_TRACE ("ACE_FILE_Connector::connect"); 00044 ACE_ASSERT (new_io.get_handle () == ACE_INVALID_HANDLE); 00045 00046 ACE_HANDLE handle = ACE_INVALID_HANDLE; 00047 00048 // Check to see if caller has requested that we create the filename. 00049 if (reinterpret_cast<const ACE_Addr &> ( 00050 const_cast<ACE_FILE_Addr &> (remote_sap)) == ACE_Addr::sap_any) 00051 { 00052 // Create a new temporary file. 00053 // Use ACE_OS::mkstemp() if it is available since it avoids a 00054 // race condition, and subsequently a security hole due to that 00055 // race condition (specifically, a denial-of-service attack). 00056 // 00057 // However, using mkstemp() prevents us from doing a timed open 00058 // since it opens the file for us. Better to avoid the race 00059 // condition. 00060 char filename[] = "ace-file-XXXXXX"; 00061 00062 handle = ACE_OS::mkstemp (filename); // mkstemp() replaces "XXXXXX" 00063 00064 if (handle == ACE_INVALID_HANDLE 00065 || new_io.addr_.set (ACE_TEXT_CHAR_TO_TCHAR (filename)) != 0) 00066 return -1; 00067 00068 new_io.set_handle (handle); 00069 00070 return 0; 00071 } 00072 else 00073 new_io.addr_ = remote_sap; // class copy. 00074 00075 handle = ACE::handle_timed_open (timeout, 00076 new_io.addr_.get_path_name (), 00077 flags, 00078 perms); 00079 00080 new_io.set_handle (handle); 00081 return handle == ACE_INVALID_HANDLE ? -1 : 0; 00082 }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_FILE_Connector::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 18 of file FILE_Connector.cpp.
References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, ACE_TRACE, and LM_DEBUG.
00019 { 00020 #if defined (ACE_HAS_DUMP) 00021 ACE_TRACE ("ACE_FILE_Connector::dump"); 00022 00023 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00024 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); 00025 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00026 #endif /* ACE_HAS_DUMP */ 00027 }
ACE_INLINE int ACE_FILE_Connector::reset_new_handle | ( | ACE_HANDLE | handle | ) |
Resets any event associations on this handle.
Definition at line 29 of file FILE_Connector.inl.
00030 { 00031 ACE_UNUSED_ARG (handle); 00032 // Nothing to do here since the handle is not a socket 00033 return 0; 00034 }