Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

SPIPE_Stream.i

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: SPIPE_Stream.i,v 1.1.1.3 2003/02/21 18:36:32 chad Exp $
00003 
00004 // SPIPE_Stream.i
00005 
00006 // Create an ACE_SPIPE_Stream.
00007 
00008 ASYS_INLINE int
00009 ACE_SPIPE_Stream::get_remote_addr (ACE_SPIPE_Addr &remote_sap) const
00010 {
00011   ACE_TRACE ("ACE_SPIPE_Stream::get_remote_addr");
00012   remote_sap = this->remote_addr_;
00013   return 0;
00014 }
00015 
00016 // Send exactly N bytes from BUF to this socket.  Keeping trying until
00017 // this many bytes are sent.
00018 
00019 ASYS_INLINE ssize_t
00020 ACE_SPIPE_Stream::send_n (const void *buf, size_t n) const
00021 {
00022   ACE_TRACE ("ACE_SPIPE_Stream::send_n");
00023   return ACE::write_n (this->get_handle (), buf, n);
00024 }
00025 
00026 // Receive exactly N bytes from this socket into BUF.  Keep trying
00027 // until this many bytes are received.
00028 
00029 ASYS_INLINE ssize_t
00030 ACE_SPIPE_Stream::recv_n (void *buf, size_t n) const
00031 {
00032   ACE_TRACE ("ACE_SPIPE_Stream::recv_n");
00033   return ACE::read_n (this->get_handle (), buf, n);
00034 }
00035 
00036 ASYS_INLINE ssize_t
00037 ACE_SPIPE_Stream::send (const void *buf, size_t n) const
00038 {
00039   ACE_TRACE ("ACE_SPIPE_Stream::send");
00040   return ACE_OS::write (this->get_handle (), (const char *) buf, n);
00041 }
00042 
00043 ASYS_INLINE ssize_t
00044 ACE_SPIPE_Stream::recv (void *buf, size_t n) const
00045 {
00046   ACE_TRACE ("ACE_SPIPE_Stream::recv");
00047   return ACE_OS::read (this->get_handle (), (char *) buf, n);
00048 }
00049 
00050 ASYS_INLINE ssize_t
00051 ACE_SPIPE_Stream::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int flags) const
00052 {
00053   ACE_TRACE ("ACE_SPIPE_Stream::send");
00054   return ACE_OS::putmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags);
00055 }
00056 
00057 ASYS_INLINE ssize_t
00058 ACE_SPIPE_Stream::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *flags) const
00059 {
00060   ACE_TRACE ("ACE_SPIPE_Stream::recv");
00061   return ACE_OS::getmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags);
00062 }
00063 
00064 ASYS_INLINE ssize_t
00065 ACE_SPIPE_Stream::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int band, int flags) const
00066 {
00067   ACE_TRACE ("ACE_SPIPE_Stream::send");
00068   return ACE_OS::putpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags);
00069 }
00070 
00071 ASYS_INLINE ssize_t
00072 ACE_SPIPE_Stream::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) const
00073 {
00074   ACE_TRACE ("ACE_SPIPE_Stream::recv");
00075   return ACE_OS::getpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags);
00076 }
00077 
00078 ASYS_INLINE ssize_t
00079 ACE_SPIPE_Stream::send (const iovec iov[], int n) const
00080 {
00081   ACE_TRACE ("ACE_SPIPE_Stream::send");
00082   return ACE_OS::writev (this->get_handle (), iov, n);
00083 }
00084 
00085 ASYS_INLINE ssize_t
00086 ACE_SPIPE_Stream::recv (iovec iov[], int n) const
00087 {
00088   ACE_TRACE ("ACE_SPIPE_Stream::recv");
00089   return ACE_OS::readv (this->get_handle (), iov, n);
00090 }
00091 
00092 // This routine sends an open file descriptor to this socket.
00093 
00094 ASYS_INLINE int
00095 ACE_SPIPE_Stream::send_handle (ACE_HANDLE handle) const
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 }
00138 
00139 // This file receives an open file descriptor from this socket.
00140 
00141 ASYS_INLINE int
00142 ACE_SPIPE_Stream::recv_handle (ACE_HANDLE &handle) const
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 }
00195 
00196 // This file receives an open file descriptor from this socket and
00197 // also passes back the information about the address...
00198 
00199 ASYS_INLINE int
00200 ACE_SPIPE_Stream::recv_handle (strrecvfd &recvfd) const
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 }
00210 
00211 ASYS_INLINE ssize_t
00212 ACE_SPIPE_Stream::send (const void *buf, size_t n,
00213                         ACE_OVERLAPPED *overlapped) const
00214 {
00215   ACE_TRACE ("ACE_SPIPE_Stream::send");
00216   return ACE_OS::write (this->get_handle (),
00217                         (const char *) buf, n,
00218                         overlapped);
00219 }
00220 
00221 ASYS_INLINE ssize_t
00222 ACE_SPIPE_Stream::recv (void *buf, size_t n,
00223                         ACE_OVERLAPPED *overlapped) const
00224 {
00225   ACE_TRACE ("ACE_SPIPE_Stream::recv");
00226   return ACE_OS::read (this->get_handle (),
00227                        (char *) buf, n,
00228                        overlapped);
00229 }
00230 
00231 ASYS_INLINE ssize_t
00232 ACE_SPIPE_Stream::sendv_n (const iovec iov[],
00233                            int n) const
00234 {
00235   ACE_TRACE ("ACE_SPIPE_Stream::sendv_n");
00236   return ACE::writev_n (this->get_handle (),
00237                         iov,
00238                         n);
00239 }
00240 
00241 // Recv an n byte message from the Stream.
00242 
00243 ASYS_INLINE ssize_t
00244 ACE_SPIPE_Stream::recvv_n (iovec iov[],
00245                            int n) const
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 }
00254 
00255 // Send an <iovec> of size <n> to the Stream.
00256 
00257 ASYS_INLINE ssize_t
00258 ACE_SPIPE_Stream::sendv (const iovec iov[],
00259                          int n) const
00260 {
00261   ACE_TRACE ("ACE_SPIPE_Stream::sendv");
00262   return ACE_OS::writev (this->get_handle (),
00263                          iov,
00264                          n);
00265 }
00266 

Generated on Mon Jun 16 11:21:23 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002