#include <SPIPE_Stream.h>
Inheritance diagram for ACE_SPIPE_Stream:


Public Types | |
| typedef ACE_SPIPE_Addr | PEER_ADDR |
Public Methods | |
| ACE_SPIPE_Stream (void) | |
| Default constructor. More... | |
| int | get_remote_addr (ACE_SPIPE_Addr &remote_sap) const |
| Obtain the address of whom we are connected with. More... | |
| int | send_handle (ACE_HANDLE handle) const |
| Send an open FD to another process. More... | |
| int | recv_handle (ACE_HANDLE &handle) const |
| Recv an open FD from another process. More... | |
| int | recv_handle (strrecvfd &recvfd) const |
| Recv an open FD from another process. More... | |
| ssize_t | send_n (const void *buf, size_t len) const |
| Send <len> bytes, keep trying until <len> are sent. More... | |
| ssize_t | recv_n (void *buf, size_t len) const |
| Recv <len> bytes, keep trying until <len> are received. More... | |
| ssize_t | send (const void *buf, size_t len) const |
| Send bytes via STREAM pipes using "band" mode. More... | |
| ssize_t | recv (void *buf, size_t len) const |
| Recv bytes via STREAM pipes using "band" mode. More... | |
| ssize_t | send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int flags=0) const |
| Send <cntl> and <data> via STREAM pipes. More... | |
| ssize_t | recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *flags) const |
| Recv <cntl> and <data> via STREAM pipes. More... | |
| ssize_t | send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int band, int flags) const |
| Send bytes via STREAM pipes using "band" mode. More... | |
| ssize_t | recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) const |
| Recv bytes via STREAM pipes using "band" mode. More... | |
| ssize_t | send (const iovec iov[], int len) const |
| Send iovecs via the OS "gather-write" operation. More... | |
| ssize_t | recv (iovec iov[], int len) const |
| Recv iovecs via the OS "scatter-read" operation. More... | |
| ssize_t | send (size_t len,...) const |
| ssize_t | recv (size_t len,...) const |
| ssize_t | send (const void *buf, size_t len, ACE_OVERLAPPED *overlapped) const |
| Send <len> bytes via Win32 <WriteFile> using overlapped I/O. More... | |
| ssize_t | recv (void *buf, size_t len, ACE_OVERLAPPED *overlapped) const |
| Recv <len> bytes via Win32 <ReadFile> using overlapped I/O. More... | |
| ssize_t | sendv (const iovec iov[], int len) const |
| Send an <iovec> of size <len> to the stream. More... | |
| ssize_t | sendv_n (const iovec iov[], int len) const |
| Send an <iovec> of size <len> to the stream. Will block until all bytes are sent or an error occurs. More... | |
| ssize_t | recvv_n (iovec iov[], int len) const |
| Receive an <iovec> of size <len> to the stream. More... | |
| void | dump (void) const |
| Dump the state of an object. More... | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. More... | |
Private Attributes | |
| ACE_SPIPE_Addr | remote_addr_ |
Friends | |
| class | ACE_SPIPE_Acceptor |
| class | ACE_SPIPE_Connector |
<buf> is the buffer to write from or receive into. <len> is the number of bytes to transfer.
The "_n()" I/O methods keep looping until all the data has been transferred. These methods also work for sockets in non-blocking mode i.e., they keep looping on EWOULDBLOCK.
The return values for the "*_n()" methods match the return values from the non "_n()" methods and are specified as follows:
The <send> and <revc> operations use "message" semantics rather than "bytestream" semantics.
Definition at line 50 of file SPIPE_Stream.h.
|
|
Definition at line 149 of file SPIPE_Stream.h. |
|
|
Default constructor.
Definition at line 23 of file SPIPE_Stream.cpp.
00024 {
00025 // ACE_TRACE ("ACE_SPIPE_Stream::ACE_SPIPE_Stream");
00026 }
|
|
|
Dump the state of an object.
Reimplemented from ACE_SPIPE. Definition at line 16 of file SPIPE_Stream.cpp. References ACE_TRACE.
00017 {
00018 ACE_TRACE ("ACE_SPIPE_Stream::dump");
00019 }
|
|
|
Obtain the address of whom we are connected with.
Definition at line 9 of file SPIPE_Stream.i. References ACE_TRACE, and remote_addr_. Referenced by ACE_UPIPE_Acceptor::accept.
00010 {
00011 ACE_TRACE ("ACE_SPIPE_Stream::get_remote_addr");
00012 remote_sap = this->remote_addr_;
00013 return 0;
00014 }
|
|
||||||||||||||||
|
Recv <len> bytes via Win32 <ReadFile> using overlapped I/O.
Definition at line 222 of file SPIPE_Stream.i. References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::read.
00224 {
00225 ACE_TRACE ("ACE_SPIPE_Stream::recv");
00226 return ACE_OS::read (this->get_handle (),
00227 (char *) buf, n,
00228 overlapped);
00229 }
|
|
||||||||||||
|
This is an interface to readv, that doesn't use the struct iovec explicitly. The ... can be passed as an arbitrary number of (char *ptr, int len) tuples. However, the count N is the *total* number of trailing arguments, *not* a couple of the number of tuple pairs! Definition at line 71 of file SPIPE_Stream.cpp. References ACE_NEW_RETURN, ACE_TRACE, iovec::iov_base, iovec::iov_len, ACE_OS::readv, and ssize_t.
00072 {
00073 ACE_TRACE ("ACE_SPIPE_Stream::recv");
00074 va_list argp;
00075 int total_tuples = ACE_static_cast (int, (n / 2));
00076 iovec *iovp;
00077 #if defined (ACE_HAS_ALLOCA)
00078 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00079 #else
00080 ACE_NEW_RETURN (iovp,
00081 iovec[total_tuples],
00082 -1);
00083 #endif /* !defined (ACE_HAS_ALLOCA) */
00084
00085 va_start (argp, n);
00086
00087 for (int i = 0; i < total_tuples; i++)
00088 {
00089 iovp[i].iov_base = va_arg (argp, char *);
00090 iovp[i].iov_len = va_arg (argp, int);
00091 }
00092
00093 ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
00094 #if !defined (ACE_HAS_ALLOCA)
00095 delete [] iovp;
00096 #endif /* !defined (ACE_HAS_ALLOCA) */
00097 va_end (argp);
00098 return result;
00099 }
|
|
||||||||||||
|
Recv iovecs via the OS "scatter-read" operation.
Definition at line 86 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::readv.
00087 {
00088 ACE_TRACE ("ACE_SPIPE_Stream::recv");
00089 return ACE_OS::readv (this->get_handle (), iov, n);
00090 }
|
|
||||||||||||||||||||
|
Recv bytes via STREAM pipes using "band" mode.
Definition at line 72 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::getpmsg.
00073 {
00074 ACE_TRACE ("ACE_SPIPE_Stream::recv");
00075 return ACE_OS::getpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags);
00076 }
|
|
||||||||||||||||
|
Recv <cntl> and <data> via STREAM pipes.
Definition at line 58 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::getmsg.
00059 {
00060 ACE_TRACE ("ACE_SPIPE_Stream::recv");
00061 return ACE_OS::getmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags);
00062 }
|
|
||||||||||||
|
Recv bytes via STREAM pipes using "band" mode.
Definition at line 44 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::read. Referenced by recv_handle, and send_handle.
00045 {
00046 ACE_TRACE ("ACE_SPIPE_Stream::recv");
00047 return ACE_OS::read (this->get_handle (), (char *) buf, n);
00048 }
|
|
|
Recv an open FD from another process.
Definition at line 200 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::ioctl.
00201 {
00202 ACE_TRACE ("ACE_SPIPE_Stream::recv_handle");
00203 #if defined (ACE_HAS_STREAM_PIPES)
00204 return ACE_OS::ioctl (this->get_handle (), I_RECVFD, (void *) &recvfd);
00205 #else
00206 ACE_UNUSED_ARG (recvfd);
00207 ACE_NOTSUP_RETURN (-1);
00208 #endif /* ACE_HAS_STREAM_PIPES */
00209 }
|
|
|
Recv an open FD from another process.
Definition at line 142 of file SPIPE_Stream.i. References ACE_TRACE, ENXIO, ACE_OS::getpid, ACE_OS::ioctl, pid_t, recv, send, ACE_OS::socket, and ssize_t.
00143 {
00144 ACE_TRACE ("ACE_SPIPE_Stream::recv_handle");
00145 #if defined (ACE_HAS_STREAM_PIPES)
00146 strrecvfd recvfd;
00147
00148 if (ACE_OS::ioctl (this->get_handle (), I_RECVFD, (void *) &recvfd) == -1)
00149 return -1;
00150 else
00151 {
00152 handle = recvfd.fd;
00153 return 0;
00154 }
00155 #elif defined (ACE_WIN32) && \
00156 (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00157 pid_t procID = ACE_OS::getpid();
00158 WSAPROTOCOL_INFO protInfo;
00159 ssize_t res;
00160 res = this->send(&procID, sizeof(procID));
00161 if (res != sizeof(procID))
00162 {
00163 if(res != -1)
00164 errno = ENXIO;
00165 return -1;
00166 }
00167 res = this->recv(&protInfo, sizeof(protInfo));
00168 if (res != sizeof(protInfo))
00169 {
00170 if(res != -1)
00171 errno = ENXIO;
00172 return -1;
00173 }
00174 handle = ACE_OS::socket (FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
00175 &protInfo, 0, 0);
00176 if (handle == ACE_INVALID_HANDLE)
00177 {
00178 return -1;
00179 }
00180 // Since it does not matter what the data is, just send something to
00181 // synchronize the end of the exchange
00182 res = this->send(&procID, sizeof(procID));
00183 if (res != sizeof(procID))
00184 {
00185 if(res != -1)
00186 errno = ENXIO;
00187 return -1;
00188 }
00189 return 0;
00190 #else
00191 handle = handle;
00192 ACE_NOTSUP_RETURN (-1);
00193 #endif /* ACE_HAS_STREAM_PIPES */
00194 }
|
|
||||||||||||
|
Recv <len> bytes, keep trying until <len> are received.
Definition at line 30 of file SPIPE_Stream.i. References ACE_TRACE, and ACE::read_n.
00031 {
00032 ACE_TRACE ("ACE_SPIPE_Stream::recv_n");
00033 return ACE::read_n (this->get_handle (), buf, n);
00034 }
|
|
||||||||||||
|
Receive an <iovec> of size <len> to the stream.
Definition at line 244 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::readv.
00246 {
00247 ACE_TRACE ("ACE_SPIPE_Stream::recvv_n");
00248 // @@ Carlos, can you please update this to call the
00249 // new ACE::recvv_n() method that you write?
00250 return ACE_OS::readv (this->get_handle (),
00251 iov,
00252 n);
00253 }
|
|
||||||||||||||||
|
Send <len> bytes via Win32 <WriteFile> using overlapped I/O.
Definition at line 212 of file SPIPE_Stream.i. References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::write.
00214 {
00215 ACE_TRACE ("ACE_SPIPE_Stream::send");
00216 return ACE_OS::write (this->get_handle (),
00217 (const char *) buf, n,
00218 overlapped);
00219 }
|
|
||||||||||||
|
Send N char *ptrs and int lengths. Note that the char *'s precede the ints (basically, an varargs version of writev). The count N is the *total* number of trailing arguments, *not* a couple of the number of tuple pairs! Definition at line 34 of file SPIPE_Stream.cpp. References ACE_NEW_RETURN, iovec::iov_base, iovec::iov_len, ssize_t, and ACE_OS::writev.
00035 {
00036 // ACE_TRACE ("ACE_SPIPE_Stream::send");
00037 va_list argp;
00038 int total_tuples = ACE_static_cast (int, (n / 2));
00039 iovec *iovp;
00040 #if defined (ACE_HAS_ALLOCA)
00041 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00042 #else
00043 ACE_NEW_RETURN (iovp,
00044 iovec[total_tuples],
00045 -1);
00046 #endif /* !defined (ACE_HAS_ALLOCA) */
00047
00048 va_start (argp, n);
00049
00050 for (int i = 0; i < total_tuples; i++)
00051 {
00052 iovp[i].iov_base = va_arg (argp, char *);
00053 iovp[i].iov_len = va_arg (argp, int);
00054 }
00055
00056 ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
00057 #if !defined (ACE_HAS_ALLOCA)
00058 delete [] iovp;
00059 #endif /* !defined (ACE_HAS_ALLOCA) */
00060 va_end (argp);
00061 return result;
00062 }
|
|
||||||||||||
|
Send iovecs via the OS "gather-write" operation.
Definition at line 79 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::writev.
00080 {
00081 ACE_TRACE ("ACE_SPIPE_Stream::send");
00082 return ACE_OS::writev (this->get_handle (), iov, n);
00083 }
|
|
||||||||||||||||||||
|
Send bytes via STREAM pipes using "band" mode.
Definition at line 65 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::putpmsg.
00066 {
00067 ACE_TRACE ("ACE_SPIPE_Stream::send");
00068 return ACE_OS::putpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags);
00069 }
|
|
||||||||||||||||
|
Send <cntl> and <data> via STREAM pipes.
Definition at line 51 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::putmsg.
00052 {
00053 ACE_TRACE ("ACE_SPIPE_Stream::send");
00054 return ACE_OS::putmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags);
00055 }
|
|
||||||||||||
|
Send bytes via STREAM pipes using "band" mode.
Definition at line 37 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::write. Referenced by recv_handle, and send_handle.
00038 {
00039 ACE_TRACE ("ACE_SPIPE_Stream::send");
00040 return ACE_OS::write (this->get_handle (), (const char *) buf, n);
00041 }
|
|
|
Send an open FD to another process.
Definition at line 95 of file SPIPE_Stream.i. References ACE_TRACE, ENXIO, ACE_OS::ioctl, recv, send, ACE_OS::set_errno_to_wsa_last_error, and ssize_t.
00096 {
00097 ACE_TRACE ("ACE_SPIPE_Stream::send_handle");
00098 #if defined (ACE_HAS_STREAM_PIPES)
00099 return ACE_OS::ioctl (this->get_handle (), I_SENDFD, (void *) handle);
00100 #elif defined (ACE_WIN32) && \
00101 (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00102 DWORD procID;
00103 WSAPROTOCOL_INFO protInfo;
00104 ssize_t res;
00105 res = this->recv(&procID, sizeof(procID));
00106 if (res != sizeof(procID))
00107 {
00108 if(res != -1)
00109 errno = ENXIO;
00110 return -1;
00111 }
00112 if (::WSADuplicateSocket ((SOCKET)handle, procID, &protInfo) == -1)
00113 {
00114 ACE_OS::set_errno_to_wsa_last_error();
00115 return -1;
00116 }
00117 res = this->send(&protInfo, sizeof(protInfo));
00118 if (res != sizeof(protInfo))
00119 {
00120 if(res != -1)
00121 errno = ENXIO;
00122 return -1;
00123 }
00124 // This is just for synchronization, we will ignore the data
00125 res = this->recv(&procID, sizeof(procID));
00126 if (res != sizeof(procID))
00127 {
00128 if(res != -1)
00129 errno = ENXIO;
00130 return -1;
00131 }
00132 return 0;
00133 #else
00134 handle = handle;
00135 ACE_NOTSUP_RETURN (-1);
00136 #endif /* ACE_HAS_STREAM_PIPES */
00137 }
|
|
||||||||||||
|
Send <len> bytes, keep trying until <len> are sent.
Definition at line 20 of file SPIPE_Stream.i. References ACE_TRACE, and ACE::write_n.
00021 {
00022 ACE_TRACE ("ACE_SPIPE_Stream::send_n");
00023 return ACE::write_n (this->get_handle (), buf, n);
00024 }
|
|
||||||||||||
|
Send an <iovec> of size <len> to the stream.
Definition at line 258 of file SPIPE_Stream.i. References ACE_TRACE, and ACE_OS::writev.
00260 {
00261 ACE_TRACE ("ACE_SPIPE_Stream::sendv");
00262 return ACE_OS::writev (this->get_handle (),
00263 iov,
00264 n);
00265 }
|
|
||||||||||||
|
Send an <iovec> of size <len> to the stream. Will block until all bytes are sent or an error occurs.
Definition at line 232 of file SPIPE_Stream.i. References ACE_TRACE, and ACE::writev_n.
00234 {
00235 ACE_TRACE ("ACE_SPIPE_Stream::sendv_n");
00236 return ACE::writev_n (this->get_handle (),
00237 iov,
00238 n);
00239 }
|
|
|
Definition at line 53 of file SPIPE_Stream.h. |
|
|
Definition at line 54 of file SPIPE_Stream.h. |
|
|
Declare the dynamic allocation hooks.
Reimplemented from ACE_SPIPE. Definition at line 155 of file SPIPE_Stream.h. |
|
|
Definition at line 158 of file SPIPE_Stream.h. Referenced by ACE_SPIPE_Acceptor::accept, ACE_SPIPE_Connector::connect, and get_remote_addr. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002