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

ACE_SOCK_IO Class Reference

Defines the methods for the ACE socket wrapper I/O routines (e.g., send/recv). More...

#include <SOCK_IO.h>

Inheritance diagram for ACE_SOCK_IO:

Inheritance graph
[legend]
Collaboration diagram for ACE_SOCK_IO:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_SOCK_IO (void)
 Constructor. More...

 ~ACE_SOCK_IO (void)
 Destructor. More...

ssize_t recv (void *buf, size_t n, int flags, const ACE_Time_Value *timeout=0) const
 Recv an <n> byte buffer from the connected socket. More...

ssize_t recv (void *buf, size_t n, const ACE_Time_Value *timeout=0) const
 Recv an <n> byte buffer from the connected socket. More...

ssize_t recvv (iovec iov[], int n, const ACE_Time_Value *timeout=0) const
 Recv an <iovec> of size <n> from the connected socket. More...

ssize_t recv (iovec iov[], size_t n, const ACE_Time_Value *timeout=0) const
 Same as above. Deprecated. More...

ssize_t recvv (iovec *io_vec, const ACE_Time_Value *timeout=0) const
ssize_t recv (iovec *io_vec, const ACE_Time_Value *timeout=0) const
 Same as above. Deprecated. More...

ssize_t recv (size_t n,...) const
 Recv <n> varargs messages to the connected socket. More...

ssize_t recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const
 Recv <n> bytes via Win32 <ReadFile> using overlapped I/O. More...

ssize_t send (const void *buf, size_t n, int flags, const ACE_Time_Value *timeout=0) const
 Send an <n> byte buffer to the connected socket. More...

ssize_t send (const void *buf, size_t n, const ACE_Time_Value *timeout=0) const
 Send an <n> byte buffer to the connected socket. More...

ssize_t sendv (const iovec iov[], int n, const ACE_Time_Value *timeout=0) const
 Send an <iovec> of size <n> to the connected socket. More...

ssize_t send (const iovec iov[], size_t n, const ACE_Time_Value *timeout=0) const
 Same as above. Deprecated. More...

ssize_t send (size_t n,...) const
 Send <n> varargs messages to the connected socket. More...

ssize_t send (const void *buf, size_t n, ACE_OVERLAPPED *overlapped) const
 Send <n> bytes via Win32 <WriteFile> using overlapped I/O. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Detailed Description

Defines the methods for the ACE socket wrapper I/O routines (e.g., send/recv).

If <timeout> == 0, then the call behaves as a normal send/recv call, i.e., for blocking sockets, the call will block until action is possible; for non-blocking sockets, EWOULDBLOCK will be returned if no action is immediately possible. If <timeout> != 0, the call will wait until the relative time specified in *<timeout> elapses. Errors are reported by -1 and 0 return values. If the operation times out, -1 is returned with <errno == ETIME>. If it succeeds the number of bytes transferred is returned. Methods with the extra <flags> argument will always result in <send> getting called. Methods without the extra <flags> argument will result in <send> getting called on Win32 platforms, and <write> getting called on non-Win32 platforms.

Definition at line 48 of file SOCK_IO.h.


Constructor & Destructor Documentation

ASYS_INLINE ACE_SOCK_IO::ACE_SOCK_IO void   
 

Constructor.

Definition at line 9 of file SOCK_IO.i.

00010 {
00011   // ACE_TRACE ("ACE_SOCK_IO::ACE_SOCK_IO");
00012 }

ASYS_INLINE ACE_SOCK_IO::~ACE_SOCK_IO void   
 

Destructor.

Definition at line 15 of file SOCK_IO.i.

00016 {
00017   // ACE_TRACE ("ACE_SOCK_IO::~ACE_SOCK_IO");
00018 }


Member Function Documentation

void ACE_SOCK_IO::dump void    const
 

Dump the state of an object.

Reimplemented from ACE_SOCK.

Reimplemented in ACE_LSOCK_CODgram.

Definition at line 17 of file SOCK_IO.cpp.

References ACE_TRACE.

00018 {
00019   ACE_TRACE ("ACE_SOCK_IO::dump");
00020 }

ASYS_INLINE ssize_t ACE_SOCK_IO::recv void *    buf,
size_t    n,
ACE_OVERLAPPED   overlapped
const
 

Recv <n> bytes via Win32 <ReadFile> using overlapped I/O.

Definition at line 79 of file SOCK_IO.i.

References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::read.

00082 {
00083   ACE_TRACE ("ACE_SOCK_IO::recv");
00084   return ACE_OS::read (this->get_handle (),
00085                        (char *) buf,
00086                        n,
00087                        overlapped);
00088 }

ssize_t ACE_SOCK_IO::recv size_t    n,
...   
const
 

Recv <n> varargs messages to the connected socket.

Definition at line 135 of file SOCK_IO.cpp.

References ACE_NEW_RETURN, ACE_TRACE, iovec::iov_base, iovec::iov_len, ACE_OS::recvv, and ssize_t.

00136 {
00137   ACE_TRACE ("ACE_SOCK_IO::recv");
00138 
00139   va_list argp;
00140   int total_tuples = ACE_static_cast (int, (n / 2));
00141   iovec *iovp;
00142 #if defined (ACE_HAS_ALLOCA)
00143   iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00144 #else
00145   ACE_NEW_RETURN (iovp,
00146                   iovec[total_tuples],
00147                   -1);
00148 #endif /* !defined (ACE_HAS_ALLOCA) */
00149 
00150   va_start (argp, n);
00151 
00152   for (int i = 0; i < total_tuples; i++)
00153     {
00154       iovp[i].iov_base = va_arg (argp, char *);
00155       iovp[i].iov_len = va_arg (argp, int);
00156     }
00157 
00158   ssize_t result = ACE_OS::recvv (this->get_handle (),
00159                                   iovp,
00160                                   total_tuples);
00161 #if !defined (ACE_HAS_ALLOCA)
00162   delete [] iovp;
00163 #endif /* !defined (ACE_HAS_ALLOCA) */
00164   va_end (argp);
00165   return result;
00166 }

ASYS_INLINE ssize_t ACE_SOCK_IO::recv iovec   io_vec,
const ACE_Time_Value   timeout = 0
const
 

Same as above. Deprecated.

Definition at line 70 of file SOCK_IO.i.

References ACE_TRACE, and recvv.

00072 {
00073   ACE_TRACE ("ACE_SOCK_IO::recv");
00074   return this->recvv (io_vec,
00075                       timeout);
00076 }

ASYS_INLINE ssize_t ACE_SOCK_IO::recv iovec    iov[],
size_t    n,
const ACE_Time_Value   timeout = 0
const
 

Same as above. Deprecated.

Definition at line 59 of file SOCK_IO.i.

References ACE_TRACE, and recvv.

00062 {
00063   ACE_TRACE ("ACE_SOCK_IO::recv");
00064   return this->recvv (iov,
00065                       ACE_static_cast (int, n),
00066                       timeout);
00067 }

ASYS_INLINE ssize_t ACE_SOCK_IO::recv void *    buf,
size_t    n,
const ACE_Time_Value   timeout = 0
const
 

Recv an <n> byte buffer from the connected socket.

Definition at line 35 of file SOCK_IO.i.

References ACE_TRACE, and ACE::recv.

00038 {
00039   ACE_TRACE ("ACE_SOCK_IO::recv");
00040   return ACE::recv (this->get_handle (),
00041                     buf,
00042                     len,
00043                     timeout);
00044 }

ASYS_INLINE ssize_t ACE_SOCK_IO::recv void *    buf,
size_t    n,
int    flags,
const ACE_Time_Value   timeout = 0
const
 

Recv an <n> byte buffer from the connected socket.

Definition at line 21 of file SOCK_IO.i.

References ACE_TRACE, and ACE::recv.

Referenced by ACE_Service_Manager::handle_input, ACE_ATM_Stream::recv, ACE_Name_Proxy::recv_reply, recvv, and ACE_Remote_Token_Proxy::request_reply.

00025 {
00026   ACE_TRACE ("ACE_SOCK_IO::recv");
00027   return ACE::recv (this->get_handle (),
00028                     buf,
00029                     len,
00030                     flags,
00031                     timeout);
00032 }

ssize_t ACE_SOCK_IO::recvv iovec   io_vec,
const ACE_Time_Value   timeout = 0
const
 

Allows a client to read from a socket without having to provide a buffer to read. This method determines how much data is in the socket, allocates a buffer of this size, reads in the data, and returns the number of bytes read. The caller is responsible for deleting the member in the <iov_base> field of <io_vec> using delete [] io_vec->iov_base.

Definition at line 28 of file SOCK_IO.cpp.

References ACE_NEW_RETURN, ACE_TRACE, ETIME, ACE_OS::ioctl, iovec::iov_base, iovec::iov_len, recv, ACE_Handle_Set::reset, ACE_OS::select, and ACE_Handle_Set::set_bit.

00030 {
00031   ACE_TRACE ("ACE_SOCK_IO::recvv");
00032 #if defined (FIONREAD)
00033   ACE_Handle_Set handle_set;
00034   handle_set.reset ();
00035   handle_set.set_bit (this->get_handle ());
00036 
00037   io_vec->iov_base = 0;
00038 
00039   // Check the status of the current socket.
00040   int select_width;
00041 #  if defined (ACE_WIN64)
00042   // This arg is ignored on Windows and causes pointer truncation
00043   // warnings on 64-bit compiles.
00044   select_width = 0;
00045 #  else
00046   select_width = int (this->get_handle ()) + 1;
00047 #  endif /* ACE_WIN64 */
00048   switch (ACE_OS::select (select_width,
00049                           handle_set,
00050                           0, 0,
00051                           timeout))
00052     {
00053     case -1:
00054       return -1;
00055       /* NOTREACHED */
00056     case 0:
00057       errno = ETIME;
00058       return -1;
00059       /* NOTREACHED */
00060     default:
00061       // Goes fine, fallthrough to get data
00062       break;
00063     }
00064 
00065   u_long inlen;
00066 
00067   if (ACE_OS::ioctl (this->get_handle (),
00068                      FIONREAD,
00069                      (u_long *) &inlen) == -1)
00070     return -1;
00071   else if (inlen > 0)
00072     {
00073       ACE_NEW_RETURN (io_vec->iov_base,
00074                       char[inlen],
00075                       -1);
00076       io_vec->iov_len = this->recv (io_vec->iov_base,
00077                                     inlen);
00078       return io_vec->iov_len;
00079     }
00080   else
00081     return 0;
00082 #else
00083   ACE_UNUSED_ARG (io_vec);
00084   ACE_UNUSED_ARG (timeout);
00085   ACE_NOTSUP_RETURN (-1);
00086 #endif /* FIONREAD */
00087 }

ASYS_INLINE ssize_t ACE_SOCK_IO::recvv iovec    iov[],
int    n,
const ACE_Time_Value   timeout = 0
const
 

Recv an <iovec> of size <n> from the connected socket.

Definition at line 47 of file SOCK_IO.i.

References ACE_TRACE, and ACE::recvv.

Referenced by recv.

00050 {
00051   ACE_TRACE ("ACE_SOCK_IO::recvv");
00052   return ACE::recvv (this->get_handle (),
00053                      iov,
00054                      n,
00055                      timeout);
00056 }

ASYS_INLINE ssize_t ACE_SOCK_IO::send const void *    buf,
size_t    n,
ACE_OVERLAPPED   overlapped
const
 

Send <n> bytes via Win32 <WriteFile> using overlapped I/O.

Definition at line 140 of file SOCK_IO.i.

References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::write.

00143 {
00144   ACE_TRACE ("ACE_SOCK_IO::send");
00145   return ACE_OS::write (this->get_handle (),
00146                         (const char *) buf,
00147                         n,
00148                         overlapped);
00149 }

ssize_t ACE_SOCK_IO::send size_t    n,
...   
const
 

Send <n> varargs messages to the connected socket.

Definition at line 95 of file SOCK_IO.cpp.

References ACE_NEW_RETURN, ACE_TRACE, iovec::iov_base, iovec::iov_len, ACE_OS::sendv, and ssize_t.

00096 {
00097   ACE_TRACE ("ACE_SOCK_IO::send");
00098 
00099   va_list argp;
00100   int total_tuples = ACE_static_cast (int, n) / 2;
00101   iovec *iovp;
00102 #if defined (ACE_HAS_ALLOCA)
00103   iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00104 #else
00105   ACE_NEW_RETURN (iovp,
00106                   iovec[total_tuples],
00107                   -1);
00108 #endif /* !defined (ACE_HAS_ALLOCA) */
00109 
00110   va_start (argp, n);
00111 
00112   for (int i = 0; i < total_tuples; i++)
00113     {
00114       iovp[i].iov_base = va_arg (argp, char *);
00115       iovp[i].iov_len = va_arg (argp, int);
00116     }
00117 
00118   ssize_t result = ACE_OS::sendv (this->get_handle (),
00119                                   iovp,
00120                                   total_tuples);
00121 #if !defined (ACE_HAS_ALLOCA)
00122   delete [] iovp;
00123 #endif /* !defined (ACE_HAS_ALLOCA) */
00124   va_end (argp);
00125   return result;
00126 }

ASYS_INLINE ssize_t ACE_SOCK_IO::send const iovec    iov[],
size_t    n,
const ACE_Time_Value   timeout = 0
const
 

Same as above. Deprecated.

Definition at line 129 of file SOCK_IO.i.

References ACE_TRACE, and sendv.

00132 {
00133   ACE_TRACE ("ACE_SOCK_IO::send");
00134   return this->sendv (iov,
00135                       ACE_static_cast (int, n),
00136                       timeout);
00137 }

ASYS_INLINE ssize_t ACE_SOCK_IO::send const void *    buf,
size_t    n,
const ACE_Time_Value   timeout = 0
const
 

Send an <n> byte buffer to the connected socket.

Definition at line 105 of file SOCK_IO.i.

References ACE_TRACE, and ACE::send.

00108 {
00109   ACE_TRACE ("ACE_SOCK_IO::send");
00110   return ACE::send (this->get_handle (),
00111                     buf,
00112                     len,
00113                     timeout);
00114 }

ASYS_INLINE ssize_t ACE_SOCK_IO::send const void *    buf,
size_t    n,
int    flags,
const ACE_Time_Value   timeout = 0
const
 

Send an <n> byte buffer to the connected socket.

Definition at line 91 of file SOCK_IO.i.

References ACE_TRACE, and ACE::send.

Referenced by ACE_Log_Msg_IPC::log.

00095 {
00096   ACE_TRACE ("ACE_SOCK_IO::send");
00097   return ACE::send (this->get_handle (),
00098                     buf,
00099                     len,
00100                     flags,
00101                     timeout);
00102 }

ASYS_INLINE ssize_t ACE_SOCK_IO::sendv const iovec    iov[],
int    n,
const ACE_Time_Value   timeout = 0
const
 

Send an <iovec> of size <n> to the connected socket.

Definition at line 117 of file SOCK_IO.i.

References ACE_TRACE, and ACE::sendv.

Referenced by send.

00120 {
00121   ACE_TRACE ("ACE_SOCK_IO::sendv");
00122   return ACE::sendv (this->get_handle (),
00123                      iov,
00124                      n,
00125                      timeout);
00126 }


Member Data Documentation

ACE_SOCK_IO::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_SOCK.

Reimplemented in ACE_LSOCK_CODgram.

Definition at line 138 of file SOCK_IO.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:56:26 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002