3 //=============================================================================
5 * @file FILE_Connector.h
7 * $Id: FILE_Connector.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Doug Schmidt <schmidt@cs.wustl.edu>
11 //=============================================================================
13 #ifndef ACE_FILE_CONNECTOR_H
14 #define ACE_FILE_CONNECTOR_H
15 #include /**/ "ace/pre.h"
17 #include "ace/FILE_IO.h"
18 #include "ace/Log_Msg.h"
19 #include "ace/os_include/os_fcntl.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 * @class ACE_FILE_Connector
30 * @brief Defines an active connection factory for the ACE_FILE wrappers.
32 * Note that the O_APPEND flag is only partly supported on Win32. If
33 * you specify O_APPEND, then the file pointer will be positioned at
34 * the end of the file initially during open, but it is not
35 * re-positioned at the end prior to each write, as specified by
36 * POSIX. This is generally good enough for typical situations, but
37 * it is ``not quite right'' in its semantics.
39 class ACE_Export ACE_FILE_Connector
42 // = Initialization methods.
43 /// Default constructor.
44 ACE_FILE_Connector (void);
47 * Actively ``connect'' and produce a @a new_io ACE_FILE_IO object
48 * if things go well. The @a remote_sap is the file that we are
49 * trying to create/open. If it's the default value of
50 * ACE_Addr::sap_any then the user is letting the OS create the
51 * filename (via <ACE_OS::mkstemp>). The @a timeout is the amount of
52 * time to wait to create/open the file. If it's 0 then we block
53 * indefinitely. If *timeout == {0, 0} then the file is created
54 * using non-blocking mode. If *timeout > {0, 0} then this is the
55 * maximum amount of time to wait before timing out. The
56 * @a local_sap and @a reuse_addr parameters are ignored. The @a flags
57 * and @a perms arguments are passed down to the <ACE_OS::open>
60 ACE_FILE_Connector (ACE_FILE_IO
&new_io
,
61 const ACE_FILE_Addr
&remote_sap
,
62 ACE_Time_Value
*timeout
= 0,
63 const ACE_Addr
&local_sap
= ACE_Addr::sap_any
,
65 int flags
= O_RDWR
| O_CREAT
,
66 int perms
= ACE_DEFAULT_FILE_PERMS
);
69 * Actively ``connect'' and produce a @a new_io <ACE_FILE_IO> object
70 * if things go well. The @a remote_sap is the file that we are
71 * trying to create/open. If it's the default value of
72 * ACE_Addr::sap_any then the user is letting the OS create the
73 * filename (via <ACE_OS::mkstemp>). The @a timeout is the amount of
74 * time to wait to create/open the file. If it's 0 then we block
75 * indefinitely. If *timeout == {0, 0} then the file is created
76 * using non-blocking mode. In this case, if the create/open can't
77 * be done immediately the value of -1 is returned with <errno ==
78 * EWOULDBLOCK>. If *timeout > {0, 0} then this is the maximum amount of
79 * time to wait before timing out. If the time expires before the
80 * connection is made @c errno == ETIME. The @a local_sap and
81 * @a reuse_addr parameters are ignored. The @a flags and @a perms
82 * arguments are passed down to the <ACE_OS::open> method.
84 int connect (ACE_FILE_IO
&new_io
,
85 const ACE_FILE_Addr
&remote_sap
,
86 ACE_Time_Value
*timeout
= 0,
87 const ACE_Addr
&local_sap
= ACE_Addr::sap_any
,
89 int flags
= O_RDWR
| O_CREAT
,
90 int perms
= ACE_DEFAULT_FILE_PERMS
);
92 /// Resets any event associations on this handle
93 int reset_new_handle (ACE_HANDLE handle
);
95 /// Dump the state of an object.
96 void dump (void) const;
98 /// Declare the dynamic allocation hooks.
99 ACE_ALLOC_HOOK_DECLARE
;
101 // = Meta-type "trait" information.
102 typedef ACE_FILE_Addr PEER_ADDR
;
103 typedef ACE_FILE_IO PEER_STREAM
;
106 ACE_END_VERSIONED_NAMESPACE_DECL
108 #if defined (__ACE_INLINE__)
109 #include "ace/FILE_Connector.inl"
110 #endif /* __ACE_INLINE__ */
112 #include /**/ "ace/post.h"
113 #endif /* ACE_FILE_CONNECTOR_H */