3 //=============================================================================
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //=============================================================================
13 #include /**/ "ace/pre.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/FILE_Addr.h"
23 // Used in the FILE_IO.h file...
24 #include "ace/os_include/os_stdio.h"
25 #include "ace/os_include/sys/os_uio.h"
27 #if defined (ACE_HAS_STREAM_PIPES)
28 # include "ace/OS_NS_stropts.h"
29 #endif /* ACE_HAS_STREAM_PIPES */
31 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
34 class ACE_Message_Block
;
40 * @brief Read/Write operations on Files
42 class ACE_Export ACE_FILE_IO
: public ACE_FILE
45 friend class ACE_FILE_Connector
;
47 /// Default constructor.
50 /// send upto @a n bytes in @a buf.
51 ssize_t
send (const void *buf
, size_t n
) const;
53 /// Recv upto @a n bytes in @a buf.
54 ssize_t
recv (void *buf
, size_t n
) const;
56 /// Send n bytes, keep trying until n are sent.
57 ssize_t
send_n (const void *buf
, size_t n
) const;
59 /// Send all the @a message_blocks chained through their next and
60 /// cont pointers. This call uses the underlying OS gather-write
61 /// operation to reduce the domain-crossing penalty.
62 ssize_t
send_n (const ACE_Message_Block
*message_block
,
63 const ACE_Time_Value
*timeout
= 0,
64 size_t *bytes_transferred
= 0);
66 /// Recv n bytes, keep trying until n are received.
67 ssize_t
recv_n (void *buf
, size_t n
) const;
69 #if defined (ACE_HAS_STREAM_PIPES)
70 /// Send bytes via STREAM pipes.
71 ssize_t
send (const ACE_Str_Buf
*cntl
,
72 const ACE_Str_Buf
*data
,
75 /// Recv bytes via STREAM pipes.
76 ssize_t
recv (ACE_Str_Buf
*cntl
,
80 /// Send bytes via STREAM pipes using "band" mode.
81 ssize_t
send (const ACE_Str_Buf
*cntl
,
82 const ACE_Str_Buf
*data
,
86 /// Recv bytes via STREAM pipes using "band" mode.
87 ssize_t
recv (ACE_Str_Buf
*cntl
,
92 #endif /* ACE_HAS_STREAM_PIPES */
94 /// Send iovecs via <::writev>.
95 ssize_t
send (const iovec iov
[], int n
) const;
97 /// Recv iovecs via <::readv>.
98 ssize_t
recv (iovec iov
[], int n
) const;
101 * Send @a n char *ptrs and int lengths. Note that the char *'s
102 * precede the ints (basically, an varargs version of writev). The
103 * count N is the *total* number of trailing arguments, *not* a
104 * couple of the number of tuple pairs!
106 ssize_t
send (size_t n
, ...) const;
109 * This is an interface to ::readv, that doesn't use the struct
110 * iovec explicitly. The ... can be passed as an arbitrary number
111 * of (char *ptr, int len) tuples. However, the count N is the
112 * *total* number of trailing arguments, *not* a couple of the
113 * number of tuple pairs!
115 ssize_t
recv (size_t n
, ...) const;
117 /// Send @a n bytes via Win32 WriteFile using overlapped I/O.
118 ssize_t
send (const void *buf
,
120 ACE_OVERLAPPED
*overlapped
) const;
122 /// Recv @a n bytes via Win32 ReadFile using overlapped I/O.
123 ssize_t
recv (void *buf
,
125 ACE_OVERLAPPED
*overlapped
) const;
127 /// Send an @c iovec of size @a n to the file.
128 ssize_t
sendv (const iovec iov
[],
132 * Allows a client to read from a file without having to provide a
133 * buffer to read. This method determines how much data is in the
134 * file, allocates a buffer of this size, reads in the data, and
135 * returns the number of bytes read. The caller is responsible for
136 * deleting the member in the <iov_base> field of <io_vec> using
137 * delete [] io_vec->iov_base.
139 ssize_t
recvv (iovec
*io_vec
);
141 /// Send an <iovec> of size @a n to the file. Will block until all
142 /// bytes are sent or an error occurs.
143 ssize_t
sendv_n (const iovec iov
[],
146 /// Receive an <iovec> of size @a n to the file.
147 ssize_t
recvv_n (iovec iov
[],
150 /// Dump the state of an object.
153 /// Declare the dynamic allocation hooks.
154 ACE_ALLOC_HOOK_DECLARE
;
157 typedef ACE_FILE_Addr PEER_ADDR
;
160 ACE_END_VERSIONED_NAMESPACE_DECL
162 #if defined (__ACE_INLINE__)
163 #include "ace/FILE_IO.inl"
164 #endif /* __ACE_INLINE__ */
166 #include /**/ "ace/post.h"
167 #endif /* ACE_FILE_IO_H */