Defines an active connection factory for the ACE_FILE wrappers. More...
#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) |
bool | 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. |
Defines an active connection factory for the ACE_FILE wrappers.
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.
{ ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector"); }
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 | |||
) | [inline] |
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.
{ ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector"); if (this->connect (new_io, remote_sap, timeout, local_sap, reuse_addr, flags, perms) == ACE_IO_SAP::INVALID_HANDLE && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) ACE_ERROR ((LM_ERROR, ACE_TEXT ("address %s, %p\n"), remote_sap.get_path_name (), ACE_TEXT ("ACE_FILE_IO"))); }
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.
{ ACE_TRACE ("ACE_FILE_Connector::connect"); ACE_ASSERT (new_io.get_handle () == ACE_INVALID_HANDLE); ACE_HANDLE handle = ACE_INVALID_HANDLE; // Check to see if caller has requested that we create the filename. if (reinterpret_cast<const ACE_Addr &> ( const_cast<ACE_FILE_Addr &> (remote_sap)) == ACE_Addr::sap_any) { // Create a new temporary file. // Use ACE_OS::mkstemp() if it is available since it avoids a // race condition, and subsequently a security hole due to that // race condition (specifically, a denial-of-service attack). // // However, using mkstemp() prevents us from doing a timed open // since it opens the file for us. Better to avoid the race // condition. char filename[] = "ace-file-XXXXXX"; handle = ACE_OS::mkstemp (filename); // mkstemp() replaces "XXXXXX" if (handle == ACE_INVALID_HANDLE || new_io.addr_.set (ACE_TEXT_CHAR_TO_TCHAR (filename)) != 0) return -1; new_io.set_handle (handle); return 0; } else new_io.addr_ = remote_sap; // class copy. handle = ACE::handle_timed_open (timeout, new_io.addr_.get_path_name (), flags, perms); new_io.set_handle (handle); return handle == ACE_INVALID_HANDLE ? -1 : 0; }
void ACE_FILE_Connector::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 18 of file FILE_Connector.cpp.
{ #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_FILE_Connector::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ }
bool ACE_FILE_Connector::reset_new_handle | ( | ACE_HANDLE | handle | ) | [inline] |
Resets any event associations on this handle.
Definition at line 29 of file FILE_Connector.inl.
{ // Nothing to do here since the handle is not a socket return false; }
Declare the dynamic allocation hooks.
Definition at line 99 of file FILE_Connector.h.