#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 len bytes, keep trying until len are sent. | |
ssize_t | recv_n (void *buf, size_t len) const |
Recv len bytes, keep trying until len 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 len bytes via Win32 using overlapped I/O. | |
ssize_t | recv (void *buf, size_t len, ACE_OVERLAPPED *overlapped) const |
Recv len bytes via Win32 using overlapped I/O. | |
ssize_t | sendv (const iovec iov[], int len) const |
Send an of size len 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 len 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 |
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:
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 len bytes via Win32 using overlapped I/O.
Definition at line 229 of file SPIPE_Stream.inl. References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::read().
00231 { 00232 ACE_TRACE ("ACE_SPIPE_Stream::recv"); 00233 return ACE_OS::read (this->get_handle (), 00234 (char *) buf, n, 00235 overlapped); 00236 } |
|
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, 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 207 of file SPIPE_Stream.inl. References ACE_NOTSUP_RETURN, ACE_TRACE, and ACE_OS::ioctl().
00208 { 00209 ACE_TRACE ("ACE_SPIPE_Stream::recv_handle"); 00210 #if defined (ACE_HAS_STREAM_PIPES) 00211 return ACE_OS::ioctl (this->get_handle (), I_RECVFD, (void *) &recvfd); 00212 #else 00213 ACE_UNUSED_ARG (recvfd); 00214 ACE_NOTSUP_RETURN (-1); 00215 #endif /* ACE_HAS_STREAM_PIPES */ 00216 } |
|
Recv an open FD from another process.
Definition at line 150 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.
00151 { 00152 ACE_TRACE ("ACE_SPIPE_Stream::recv_handle"); 00153 #if defined (ACE_HAS_STREAM_PIPES) 00154 strrecvfd recvfd; 00155 00156 if (ACE_OS::ioctl (this->get_handle (), I_RECVFD, (void *) &recvfd) == -1) 00157 return -1; 00158 else 00159 { 00160 handle = recvfd.fd; 00161 return 0; 00162 } 00163 #elif defined (ACE_WIN32) && \ 00164 (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) 00165 pid_t procID = ACE_OS::getpid(); 00166 WSAPROTOCOL_INFO protInfo; 00167 ssize_t res = this->send(&procID, sizeof(procID)); 00168 if (res != sizeof(procID)) 00169 { 00170 if(res != -1) 00171 errno = ENXIO; 00172 return -1; 00173 } 00174 res = this->recv(&protInfo, sizeof(protInfo)); 00175 if (res != sizeof(protInfo)) 00176 { 00177 if(res != -1) 00178 errno = ENXIO; 00179 return -1; 00180 } 00181 handle = ACE_OS::socket (FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, 00182 &protInfo, 0, 0); 00183 if (handle == ACE_INVALID_HANDLE) 00184 { 00185 return -1; 00186 } 00187 // Since it does not matter what the data is, just send something to 00188 // synchronize the end of the exchange 00189 res = this->send(&procID, sizeof(procID)); 00190 if (res != sizeof(procID)) 00191 { 00192 if(res != -1) 00193 errno = ENXIO; 00194 return -1; 00195 } 00196 return 0; 00197 #else 00198 handle = handle; 00199 ACE_NOTSUP_RETURN (-1); 00200 #endif /* ACE_HAS_STREAM_PIPES */ 00201 } |
|
Recv len bytes, keep trying until len 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 len to the stream.
Definition at line 251 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::readv().
00253 { 00254 ACE_TRACE ("ACE_SPIPE_Stream::recvv_n"); 00255 // @@ Carlos, can you please update this to call the 00256 // new ACE::recvv_n() method that you write? 00257 return ACE_OS::readv (this->get_handle (), 00258 iov, 00259 n); 00260 } |
|
Send len bytes via Win32 using overlapped I/O.
Definition at line 219 of file SPIPE_Stream.inl. References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::write().
00221 { 00222 ACE_TRACE ("ACE_SPIPE_Stream::send"); 00223 return ACE_OS::write (this->get_handle (), 00224 (const char *) buf, n, 00225 overlapped); 00226 } |
|
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, 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 = this->recv(&procID, sizeof(procID)); 00114 if (res != sizeof(procID)) 00115 { 00116 if(res != -1) 00117 errno = ENXIO; 00118 return -1; 00119 } 00120 if (::WSADuplicateSocket ((SOCKET)handle, procID, &protInfo) == -1) 00121 { 00122 ACE_OS::set_errno_to_wsa_last_error(); 00123 return -1; 00124 } 00125 res = this->send(&protInfo, sizeof(protInfo)); 00126 if (res != sizeof(protInfo)) 00127 { 00128 if(res != -1) 00129 errno = ENXIO; 00130 return -1; 00131 } 00132 // This is just for synchronization, we will ignore the data 00133 res = this->recv(&procID, sizeof(procID)); 00134 if (res != sizeof(procID)) 00135 { 00136 if(res != -1) 00137 errno = ENXIO; 00138 return -1; 00139 } 00140 return 0; 00141 #else 00142 handle = handle; 00143 ACE_NOTSUP_RETURN (-1); 00144 #endif /* ACE_HAS_STREAM_PIPES */ 00145 } |
|
Send len bytes, keep trying until len 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 len to the stream.
Definition at line 265 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE_OS::writev().
00267 { 00268 ACE_TRACE ("ACE_SPIPE_Stream::sendv"); 00269 return ACE_OS::writev (this->get_handle (), 00270 iov, 00271 n); 00272 } |
|
Send an of size len to the stream. Will block until all bytes are sent or an error occurs. Definition at line 239 of file SPIPE_Stream.inl. References ACE_TRACE, and ACE::writev_n().
00241 { 00242 ACE_TRACE ("ACE_SPIPE_Stream::sendv_n"); 00243 return ACE::writev_n (this->get_handle (), 00244 iov, 00245 n); 00246 } |
|
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(). |