3 //=============================================================================
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //=============================================================================
11 #ifndef ACE_SPIPE_STREAM_H
12 #define ACE_SPIPE_STREAM_H
13 #include /**/ "ace/pre.h"
15 #include "ace/SPIPE.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/SPIPE_Addr.h"
23 #include "ace/OS_NS_stropts.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 * @class ACE_SPIPE_Stream
30 * @brief Defines the methods in the ACE_SPIPE_Stream abstraction.
32 * @a buf is the buffer to write from or receive into.
33 * @a len is the number of bytes to transfer.
35 * The "_n()" I/O methods keep looping until all the data has been
36 * transferred. These methods also work for sockets in non-blocking
37 * mode i.e., they keep looping on EWOULDBLOCK.
39 * The return values for the "*_n()" methods match the return values
40 * from the non "_n()" methods and are specified as follows:
41 * - The number of bytes transferred is returned.
42 * - On error, -1 is returned, errno is set to appropriate error.
43 * - On EOF, 0 is returned, errno is irrelevant.
45 * Methods with <iovec> parameter are I/O vector variants of the I/O
48 * The <send> and <revc> operations use "message" semantics rather
49 * than "bytestream" semantics.
51 class ACE_Export ACE_SPIPE_Stream
: public ACE_SPIPE
54 friend class ACE_SPIPE_Acceptor
;
55 friend class ACE_SPIPE_Connector
;
57 /// Default constructor.
58 ACE_SPIPE_Stream (void);
60 /// Obtain the address of whom we are connected with.
61 int get_remote_addr (ACE_SPIPE_Addr
&remote_sap
) const;
63 /// Send an open FD to another process.
64 int send_handle (ACE_HANDLE handle
) const;
66 /// Recv an open FD from another process.
67 int recv_handle (ACE_HANDLE
&handle
) const;
69 /// Recv an open FD from another process.
70 int recv_handle (strrecvfd
&recvfd
) const;
72 /// Send @a len bytes, keep trying until @a len are sent.
73 ssize_t
send_n (const void *buf
, size_t len
) const;
75 /// Recv @a len bytes, keep trying until @a len are received.
76 ssize_t
recv_n (void *buf
, size_t len
) const;
78 /// Send bytes via STREAM pipes using "band" mode.
79 ssize_t
send (const void *buf
, size_t len
) const;
81 /// Recv bytes via STREAM pipes using "band" mode.
82 ssize_t
recv (void *buf
, size_t len
) const;
84 /// Send @a cntl and @a data via STREAM pipes.
85 ssize_t
send (const ACE_Str_Buf
*cntl
,
86 const ACE_Str_Buf
*data
,
89 /// Recv @a cntl and @a data via STREAM pipes.
90 ssize_t
recv (ACE_Str_Buf
*cntl
,
94 /// Send bytes via STREAM pipes using "band" mode.
95 ssize_t
send (const ACE_Str_Buf
*cntl
,
96 const ACE_Str_Buf
*data
,
100 /// Recv bytes via STREAM pipes using "band" mode.
101 ssize_t
recv (ACE_Str_Buf
*cntl
,
106 /// Send iovecs via the OS "gather-write" operation.
107 ssize_t
send (const iovec iov
[], int len
) const;
109 /// Recv iovecs via the OS "scatter-read" operation.
110 ssize_t
recv (iovec iov
[], int len
) const;
112 #ifndef ACE_LACKS_VA_FUNCTIONS
114 * Send N char *ptrs and int lengths. Note that the char *'s
115 * precede the ints (basically, an varargs version of writev). The
116 * count N is the *total* number of trailing arguments, *not* a
117 * couple of the number of tuple pairs!
119 ssize_t
send (size_t len
, ...) const;
122 * This is an interface to ::readv, that doesn't use the struct
123 * iovec explicitly. The ... can be passed as an arbitrary number
124 * of (char *ptr, int len) tuples. However, the count N is the
125 * *total* number of trailing arguments, *not* a couple of the
126 * number of tuple pairs!
128 ssize_t
recv (size_t len
, ...) const;
131 /// Send @a len bytes via Win32 <WriteFile> using overlapped I/O.
132 ssize_t
send (const void *buf
, size_t len
, ACE_OVERLAPPED
*overlapped
) const;
134 /// Recv @a len bytes via Win32 <ReadFile> using overlapped I/O.
135 ssize_t
recv (void *buf
, size_t len
, ACE_OVERLAPPED
*overlapped
) const;
137 /// Send an <iovec> of size @a len to the stream.
138 ssize_t
sendv (const iovec iov
[],
141 /// Send an <iovec> of size @a len to the stream. 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 len from the stream.
147 ssize_t
recvv_n (iovec iov
[],
151 typedef ACE_SPIPE_Addr PEER_ADDR
;
153 /// Dump the state of an object.
154 void dump (void) const;
156 /// Declare the dynamic allocation hooks.
157 ACE_ALLOC_HOOK_DECLARE
;
160 ACE_SPIPE_Addr remote_addr_
;
163 ACE_END_VERSIONED_NAMESPACE_DECL
165 #if defined (__ACE_INLINE__)
166 #include "ace/SPIPE_Stream.inl"
167 #endif /* __ACE_INLINE__ */
169 #include /**/ "ace/post.h"
170 #endif /* ACE_SPIPE_STREAM_H */