Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_FILE_Connector Class Reference

Defines an active connection factory for the ACE_FILE wrappers. More...

#include <FILE_Connector.h>

List of all members.

Public Types

typedef ACE_FILE_Addr PEER_ADDR
typedef ACE_FILE_IO PEER_STREAM

Public Methods

 ACE_FILE_Connector (void)
 Default constructor. More...

 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. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Detailed Description

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 36 of file FILE_Connector.h.


Member Typedef Documentation

typedef ACE_FILE_Addr ACE_FILE_Connector::PEER_ADDR
 

Definition at line 101 of file FILE_Connector.h.

typedef ACE_FILE_IO ACE_FILE_Connector::PEER_STREAM
 

Definition at line 102 of file FILE_Connector.h.


Constructor & Destructor Documentation

ACE_FILE_Connector::ACE_FILE_Connector void   
 

Default constructor.

Definition at line 26 of file FILE_Connector.cpp.

References ACE_TRACE.

00027 {
00028   ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector");
00029 }

ASYS_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::mktemp>). 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 9 of file FILE_Connector.i.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, connect, ETIME, EWOULDBLOCK, ACE_FILE_Addr::get_path_name, ACE_IO_SAP::INVALID_HANDLE, and LM_ERROR.

00016 {
00017   ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector");
00018   if (this->connect (new_io, remote_sap, timeout, local_sap,
00019                      reuse_addr, flags, perms) == ACE_IO_SAP::INVALID_HANDLE
00020       && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
00021     ACE_ERROR ((LM_ERROR,
00022                 ACE_LIB_TEXT ("address %s, %p\n"),
00023                 remote_sap.get_path_name (),
00024                 ACE_LIB_TEXT ("ACE_FILE_IO")));
00025 }


Member Function Documentation

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::mktemp>). 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 32 of file FILE_Connector.cpp.

References ACE_ASSERT, ACE_TRACE, ACE_FILE::addr_, ACE_IO_SAP::get_handle, ACE_FILE_Addr::get_path_name, ACE_Handle_Ops::handle_timed_open, ACE_OS::mkstemp, ACE_Addr::sap_any, ACE_FILE_Addr::set, and ACE_IO_SAP::set_handle.

Referenced by ACE_FILE_Connector.

00039 {
00040   ACE_TRACE ("ACE_FILE_Connector::connect");
00041   ACE_ASSERT (new_io.get_handle () == ACE_INVALID_HANDLE);
00042 
00043   ACE_HANDLE handle = ACE_INVALID_HANDLE;
00044 
00045   // Check to see if caller has requested that we create the filename.
00046   if (ACE_reinterpret_cast (const ACE_Addr &,
00047                             ACE_const_cast (ACE_FILE_Addr &,
00048                                             remote_sap)) == ACE_Addr::sap_any)
00049     {
00050       // Create a new temporary file.
00051 #ifdef ACE_LACKS_MKSTEMP
00052       new_io.addr_ =
00053         ACE_FILE_Addr (ACE_sap_any_cast (ACE_FILE_Addr &)); // class copy.
00054 #else
00055       // Use ACE_OS::mkstemp() if it is available since it avoids a
00056       // race condition, and subsequently a security hole due to that
00057       // race condition (specifically, a denial-of-service attack).
00058       //
00059       // However, using mkstemp() prevents us from doing a timed open
00060       // since it opens the file for us.  Better to avoid the race
00061       // condition.
00062       char filename[] = "ace-file-XXXXXX";
00063 
00064       handle = ACE_OS::mkstemp (filename); // mkstemp() replaces "XXXXXX"
00065 
00066       if (handle == ACE_INVALID_HANDLE
00067           || new_io.addr_.set (filename) != 0)
00068         return -1;
00069 
00070       new_io.set_handle (handle);
00071 
00072       return 0;
00073 #endif  /* ACE_LACKS_MKSTEMP */
00074     }
00075   else
00076     new_io.addr_ = remote_sap; // class copy.
00077 
00078   handle = ACE_Handle_Ops::handle_timed_open (timeout,
00079                                               new_io.addr_.get_path_name (),
00080                                               flags,
00081                                               perms);
00082 
00083   new_io.set_handle (handle);
00084   return handle == ACE_INVALID_HANDLE ? -1 : 0;
00085 }

void ACE_FILE_Connector::dump void    const
 

Dump the state of an object.

Definition at line 17 of file FILE_Connector.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.

00018 {
00019   ACE_TRACE ("ACE_FILE_Connector::dump");
00020 
00021   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00022   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\n")));
00023   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00024 }

ASYS_INLINE int ACE_FILE_Connector::reset_new_handle ACE_HANDLE    handle
 

Resets any event associations on this handle.

Definition at line 28 of file FILE_Connector.i.

00029 {
00030   ACE_UNUSED_ARG (handle);
00031   // Nothing to do here since the handle is not a socket
00032   return 0;
00033 }


Member Data Documentation

ACE_FILE_Connector::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 98 of file FILE_Connector.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:47:53 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002