#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 104 of file FILE_Connector.h. |
|
|
Definition at line 105 of file FILE_Connector.h. |
|
|
Default constructor.
Definition at line 30 of file FILE_Connector.cpp. References ACE_TRACE.
00031 {
00032 ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector");
00033 }
|
|
||||||||||||||||||||||||||||||||
|
Actively ``connect'' and produce a object if things go well. The 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::mktemp>). The 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 and parameters are ignored. The and arguments are passed down to the <ACE_OS::open> method. Definition at line 10 of file FILE_Connector.inl. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, connect(), ETIME, EWOULDBLOCK, ACE_FILE_Addr::get_path_name(), 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_LIB_TEXT ("address %s, %p\n"),
00024 remote_sap.get_path_name (),
00025 ACE_LIB_TEXT ("ACE_FILE_IO")));
00026 }
|
|
||||||||||||||||||||||||||||||||
|
Actively ``connect'' and produce a object if things go well. The 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::mktemp>). The 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 and parameters are ignored. The and arguments are passed down to the <ACE_OS::open> method. Definition at line 36 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_FILE_Addr::set(), and ACE_IO_SAP::set_handle(). Referenced by ACE_FILE_Connector().
00043 {
00044 ACE_TRACE ("ACE_FILE_Connector::connect");
00045 ACE_ASSERT (new_io.get_handle () == ACE_INVALID_HANDLE);
00046
00047 ACE_HANDLE handle = ACE_INVALID_HANDLE;
00048
00049 // Check to see if caller has requested that we create the filename.
00050 if (reinterpret_cast<const ACE_Addr &> (
00051 const_cast<ACE_FILE_Addr &> (remote_sap)) == ACE_Addr::sap_any)
00052 {
00053 // Create a new temporary file.
00054 #ifdef ACE_LACKS_MKSTEMP
00055 new_io.addr_ =
00056 ACE_FILE_Addr (ACE_sap_any_cast (ACE_FILE_Addr &)); // class copy.
00057 #else
00058 // Use ACE_OS::mkstemp() if it is available since it avoids a
00059 // race condition, and subsequently a security hole due to that
00060 // race condition (specifically, a denial-of-service attack).
00061 //
00062 // However, using mkstemp() prevents us from doing a timed open
00063 // since it opens the file for us. Better to avoid the race
00064 // condition.
00065 char filename[] = "ace-file-XXXXXX";
00066
00067 handle = ACE_OS::mkstemp (filename); // mkstemp() replaces "XXXXXX"
00068
00069 if (handle == ACE_INVALID_HANDLE
00070 || new_io.addr_.set (ACE_TEXT_CHAR_TO_TCHAR (filename)) != 0)
00071 return -1;
00072
00073 new_io.set_handle (handle);
00074
00075 return 0;
00076 #endif /* ACE_LACKS_MKSTEMP */
00077 }
00078 else
00079 new_io.addr_ = remote_sap; // class copy.
00080
00081 handle = ACE::handle_timed_open (timeout,
00082 new_io.addr_.get_path_name (),
00083 flags,
00084 perms);
00085
00086 new_io.set_handle (handle);
00087 return handle == ACE_INVALID_HANDLE ? -1 : 0;
00088 }
|
|
|
Dump the state of an object.
Definition at line 19 of file FILE_Connector.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.
|
|
|
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 }
|
|
|
Declare the dynamic allocation hooks.
Definition at line 101 of file FILE_Connector.h. |
1.3.6