#include <SPIPE_Stream.h>
Inheritance diagram for ACE_SPIPE_Stream:
Public Types | |
typedef ACE_SPIPE_Addr | PEER_ADDR |
Public Member Functions | |
ACE_SPIPE_Stream (void) | |
Default constructor. | |
int | get_remote_addr (ACE_SPIPE_Addr &remote_sap) const |
Obtain the address of whom we are connected with. | |
int | send_handle (ACE_HANDLE handle) const |
Send an open FD to another process. | |
int | recv_handle (ACE_HANDLE &handle) const |
Recv an open FD from another process. | |
int | recv_handle (strrecvfd &recvfd) const |
Recv an open FD from another process. | |
ssize_t | send_n (const void *buf, size_t len) const |
Send bytes, keep trying until are sent. | |
ssize_t | recv_n (void *buf, size_t len) const |
Recv bytes, keep trying until are received. | |
ssize_t | send (const void *buf, size_t len) const |
Send bytes via STREAM pipes using "band" mode. | |
ssize_t | recv (void *buf, size_t len) const |
Recv bytes via STREAM pipes using "band" mode. | |
ssize_t | send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int flags=0) const |
Send and via STREAM pipes. | |
ssize_t | recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *flags) const |
Recv and via STREAM pipes. | |
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. | |
ssize_t | recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) const |
Recv bytes via STREAM pipes using "band" mode. | |
ssize_t | send (const iovec iov[], int len) const |
Send iovecs via the OS "gather-write" operation. | |
ssize_t | recv (iovec iov[], int len) const |
Recv iovecs via the OS "scatter-read" operation. | |
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 bytes via Win32 using overlapped I/O. | |
ssize_t | recv (void *buf, size_t len, ACE_OVERLAPPED *overlapped) const |
Recv bytes via Win32 using overlapped I/O. | |
ssize_t | sendv (const iovec iov[], int len) const |
Send an of size to the stream. | |
ssize_t | sendv_n (const iovec iov[], int len) const |
ssize_t | recvv_n (iovec iov[], int len) const |
Receive an of size to the stream. | |
void | dump (void) const |
Dump the state of an object. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Private Attributes | |
ACE_SPIPE_Addr | remote_addr_ |
Friends | |
class | ACE_SPIPE_Acceptor |
class | ACE_SPIPE_Connector |
is the buffer to write from or receive into. 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:
Methods with parameter are I/O vector variants of the I/O operations.
The and operations use "message" semantics rather than "bytestream" semantics.
Definition at line 53 of file SPIPE_Stream.h.
|
Definition at line 152 of file SPIPE_Stream.h. |
|
Default constructor.
Definition at line 26 of file SPIPE_Stream.cpp.
00027 {
00028 // ACE_TRACE ("ACE_SPIPE_Stream::ACE_SPIPE_Stream");
00029 }
|
|
Dump the state of an object.
Reimplemented from ACE_SPIPE. Definition at line 17 of file SPIPE_Stream.cpp. References ACE_TRACE.
00018 { 00019 #if defined (ACE_HAS_DUMP) 00020 ACE_TRACE ("ACE_SPIPE_Stream::dump"); 00021 #endif /* ACE_HAS_DUMP */ 00022 } |
|
Obtain the address of whom we are connected with.
Definition at line 17 of file SPIPE_Stream.inl. References ACE_TRACE, and remote_addr_. Referenced by ACE_UPIPE_Acceptor::accept().
00018 { 00019 ACE_TRACE ("ACE_SPIPE_Stream::get_remote_addr"); 00020 remote_sap = this->remote_addr_; 00021 return 0; 00022 } |
|
Recv bytes via Win32 using overlapped I/O.
Definition at line 231 of file SPIPE_Stream.inl. References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::read().
00233 { 00234 ACE_TRACE ("ACE_SPIPE_Stream::recv"); 00235 return ACE_OS::read (this->get_handle (), 00236 (char *) buf, n, 00237 overlapped); 00238 } |
|
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 74 of file SPIPE_Stream.cpp. References ACE_NEW_RETURN, ACE_TRACE, iovec::iov_base, iovec::iov_len, ACE_OS::readv(), and ssize_t.
00075 { 00076 ACE_TRACE ("ACE_SPIPE_Stream::recv"); 00077 va_list argp; 00078 int total_tuples = static_cast<int> (n / 2); 00079 iovec *iovp; 00080 #if defined (ACE_HAS_ALLOCA) 00081 iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); 00082 #else 00083 ACE_NEW_RETURN (iovp, 00084 iovec[total_tuples], 00085 -1); 00086 #endif /* !defined (ACE_HAS_ALLOCA) */ 00087 00088 va_start (argp, n); 00089 00090 for (int i = 0; i < total_tuples; i++) 00091 { 00092 iovp[i].iov_base = va_arg (argp, char *); 00093 iovp[i].iov_len = va_arg (argp, int); 00094 } 00095 00096 ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); 00097 #if !defined (ACE_HAS_ALLOCA) 00098 delete [] iovp; 00099 #endif /* !defined (ACE_HAS_ALLOCA) */ 00100 va_end (argp); 00101 return result; 00102 } |
|
Recv iovecs via the OS "scatter-read" operation.
Definition at line 94 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::readv().
00095 { 00096 ACE_TRACE ("ACE_SPIPE_Stream::recv"); 00097 return ACE_OS::readv (this->get_handle (), iov, n); 00098 } |
|
Recv bytes via STREAM pipes using "band" mode.
Definition at line 80 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::getpmsg().
00081 { 00082 ACE_TRACE ("ACE_SPIPE_Stream::recv"); 00083 return ACE_OS::getpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); 00084 } |
|
Recv and via STREAM pipes.
Definition at line 66 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::getmsg().
00067 { 00068 ACE_TRACE ("ACE_SPIPE_Stream::recv"); 00069 return ACE_OS::getmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); 00070 } |
|
Recv bytes via STREAM pipes using "band" mode.
Definition at line 52 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::read(). Referenced by recv_handle(), and send_handle().
00053 { 00054 ACE_TRACE ("ACE_SPIPE_Stream::recv"); 00055 return ACE_OS::read (this->get_handle (), (char *) buf, n); 00056 } |
|
Recv an open FD from another process.
Definition at line 209 of file SPIPE_Stream.inl. References ACE_NOTSUP_RETURN, ACE_TRACE, and ACE_OS::ioctl().
00210 { 00211 ACE_TRACE ("ACE_SPIPE_Stream::recv_handle"); 00212 #if defined (ACE_HAS_STREAM_PIPES) 00213 return ACE_OS::ioctl (this->get_handle (), I_RECVFD, (void *) &recvfd); 00214 #else 00215 ACE_UNUSED_ARG (recvfd); 00216 ACE_NOTSUP_RETURN (-1); 00217 #endif /* ACE_HAS_STREAM_PIPES */ 00218 } |
|
Recv an open FD from another process.
Definition at line 151 of file SPIPE_Stream.inl. References ACE_NOTSUP_RETURN, ACE_TRACE, ENXIO, ACE_OS::getpid(), ACE_OS::ioctl(), pid_t, recv(), send(), ACE_OS::socket(), and ssize_t.
00152 { 00153 ACE_TRACE ("ACE_SPIPE_Stream::recv_handle"); 00154 #if defined (ACE_HAS_STREAM_PIPES) 00155 strrecvfd recvfd; 00156 00157 if (ACE_OS::ioctl (this->get_handle (), I_RECVFD, (void *) &recvfd) == -1) 00158 return -1; 00159 else 00160 { 00161 handle = recvfd.fd; 00162 return 0; 00163 } 00164 #elif defined (ACE_WIN32) && \ 00165 (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) 00166 pid_t procID = ACE_OS::getpid(); 00167 WSAPROTOCOL_INFO protInfo; 00168 ssize_t res; 00169 res = this->send(&procID, sizeof(procID)); 00170 if (res != sizeof(procID)) 00171 { 00172 if(res != -1) 00173 errno = ENXIO; 00174 return -1; 00175 } 00176 res = this->recv(&protInfo, sizeof(protInfo)); 00177 if (res != sizeof(protInfo)) 00178 { 00179 if(res != -1) 00180 errno = ENXIO; 00181 return -1; 00182 } 00183 handle = ACE_OS::socket (FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, 00184 &protInfo, 0, 0); 00185 if (handle == ACE_INVALID_HANDLE) 00186 { 00187 return -1; 00188 } 00189 // Since it does not matter what the data is, just send something to 00190 // synchronize the end of the exchange 00191 res = this->send(&procID, sizeof(procID)); 00192 if (res != sizeof(procID)) 00193 { 00194 if(res != -1) 00195 errno = ENXIO; 00196 return -1; 00197 } 00198 return 0; 00199 #else 00200 handle = handle; 00201 ACE_NOTSUP_RETURN (-1); 00202 #endif /* ACE_HAS_STREAM_PIPES */ 00203 } |
|
Recv bytes, keep trying until are received.
Definition at line 38 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE::read_n().
00039 { 00040 ACE_TRACE ("ACE_SPIPE_Stream::recv_n"); 00041 return ACE::read_n (this->get_handle (), buf, n); 00042 } |
|
Receive an of size to the stream.
Definition at line 253 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::readv().
00255 { 00256 ACE_TRACE ("ACE_SPIPE_Stream::recvv_n"); 00257 // @@ Carlos, can you please update this to call the 00258 // new ACE::recvv_n() method that you write? 00259 return ACE_OS::readv (this->get_handle (), 00260 iov, 00261 n); 00262 } |
|
Send bytes via Win32 using overlapped I/O.
Definition at line 221 of file SPIPE_Stream.inl. References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::write().
00223 { 00224 ACE_TRACE ("ACE_SPIPE_Stream::send"); 00225 return ACE_OS::write (this->get_handle (), 00226 (const char *) buf, n, 00227 overlapped); 00228 } |
|
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 37 of file SPIPE_Stream.cpp. References ACE_NEW_RETURN, iovec::iov_base, iovec::iov_len, ssize_t, and ACE_OS::writev().
00038 { 00039 // ACE_TRACE ("ACE_SPIPE_Stream::send"); 00040 va_list argp; 00041 int total_tuples = static_cast<int> (n / 2); 00042 iovec *iovp; 00043 #if defined (ACE_HAS_ALLOCA) 00044 iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); 00045 #else 00046 ACE_NEW_RETURN (iovp, 00047 iovec[total_tuples], 00048 -1); 00049 #endif /* !defined (ACE_HAS_ALLOCA) */ 00050 00051 va_start (argp, n); 00052 00053 for (int i = 0; i < total_tuples; i++) 00054 { 00055 iovp[i].iov_base = va_arg (argp, char *); 00056 iovp[i].iov_len = va_arg (argp, int); 00057 } 00058 00059 ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); 00060 #if !defined (ACE_HAS_ALLOCA) 00061 delete [] iovp; 00062 #endif /* !defined (ACE_HAS_ALLOCA) */ 00063 va_end (argp); 00064 return result; 00065 } |
|
Send iovecs via the OS "gather-write" operation.
Definition at line 87 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::writev().
00088 { 00089 ACE_TRACE ("ACE_SPIPE_Stream::send"); 00090 return ACE_OS::writev (this->get_handle (), iov, n); 00091 } |
|
Send bytes via STREAM pipes using "band" mode.
Definition at line 73 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::putpmsg().
00074 { 00075 ACE_TRACE ("ACE_SPIPE_Stream::send"); 00076 return ACE_OS::putpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); 00077 } |
|
Send and via STREAM pipes.
Definition at line 59 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::putmsg().
00060 { 00061 ACE_TRACE ("ACE_SPIPE_Stream::send"); 00062 return ACE_OS::putmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); 00063 } |
|
Send bytes via STREAM pipes using "band" mode.
Definition at line 45 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::write(). Referenced by recv_handle(), and send_handle().
00046 { 00047 ACE_TRACE ("ACE_SPIPE_Stream::send"); 00048 return ACE_OS::write (this->get_handle (), (const char *) buf, n); 00049 } |
|
Send an open FD to another process.
Definition at line 103 of file SPIPE_Stream.inl. References ACE_NOTSUP_RETURN, ACE_TRACE, ENXIO, ACE_OS::ioctl(), recv(), send(), ACE_OS::set_errno_to_wsa_last_error(), and ssize_t.
00104 { 00105 ACE_TRACE ("ACE_SPIPE_Stream::send_handle"); 00106 #if defined (ACE_HAS_STREAM_PIPES) 00107 return ACE_OS::ioctl (this->get_handle (), I_SENDFD, (void *) handle); 00108 #elif defined (ACE_WIN32) && \ 00109 (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) && \ 00110 !defined (ACE_HAS_WINCE) /* CE4 has WS2 but not WSADuplicateSocket */ 00111 DWORD procID; 00112 WSAPROTOCOL_INFO protInfo; 00113 ssize_t res; 00114 res = this->recv(&procID, sizeof(procID)); 00115 if (res != sizeof(procID)) 00116 { 00117 if(res != -1) 00118 errno = ENXIO; 00119 return -1; 00120 } 00121 if (::WSADuplicateSocket ((SOCKET)handle, procID, &protInfo) == -1) 00122 { 00123 ACE_OS::set_errno_to_wsa_last_error(); 00124 return -1; 00125 } 00126 res = this->send(&protInfo, sizeof(protInfo)); 00127 if (res != sizeof(protInfo)) 00128 { 00129 if(res != -1) 00130 errno = ENXIO; 00131 return -1; 00132 } 00133 // This is just for synchronization, we will ignore the data 00134 res = this->recv(&procID, sizeof(procID)); 00135 if (res != sizeof(procID)) 00136 { 00137 if(res != -1) 00138 errno = ENXIO; 00139 return -1; 00140 } 00141 return 0; 00142 #else 00143 handle = handle; 00144 ACE_NOTSUP_RETURN (-1); 00145 #endif /* ACE_HAS_STREAM_PIPES */ 00146 } |
|
Send bytes, keep trying until are sent.
Definition at line 28 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE::write_n().
00029 { 00030 ACE_TRACE ("ACE_SPIPE_Stream::send_n"); 00031 return ACE::write_n (this->get_handle (), buf, n); 00032 } |
|
Send an of size to the stream.
Definition at line 267 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::writev().
00269 { 00270 ACE_TRACE ("ACE_SPIPE_Stream::sendv"); 00271 return ACE_OS::writev (this->get_handle (), 00272 iov, 00273 n); 00274 } |
|
Send an of size to the stream. Will block until all bytes are sent or an error occurs. Definition at line 241 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE::writev_n().
00243 { 00244 ACE_TRACE ("ACE_SPIPE_Stream::sendv_n"); 00245 return ACE::writev_n (this->get_handle (), 00246 iov, 00247 n); 00248 } |
|
Definition at line 56 of file SPIPE_Stream.h. |
|
Definition at line 57 of file SPIPE_Stream.h. |
|
Declare the dynamic allocation hooks.
Reimplemented from ACE_SPIPE. Definition at line 158 of file SPIPE_Stream.h. |
|
Definition at line 161 of file SPIPE_Stream.h. Referenced by ACE_SPIPE_Acceptor::accept(), ACE_SPIPE_Connector::connect(), and get_remote_addr(). |