#include <DEV_IO.h>
Inheritance diagram for ACE_DEV_IO:


I/O operations | |
| Notes on common parameters: buf is the buffer to write from or receive into. len is the number of bytes to transfer. The timeout parameter in the following methods indicates how long to blocking trying to transfer data. 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. 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. timeout is used to make sure we keep making progress, i.e., the same timeout value is used for every I/O operation in the loop and the timeout is not counted down. The return values for the "*_n()" methods match the return values from the non "_n()" methods and are specified as follows: 
 
 
On partial transfers, i.e., if any data is transferred before timeout/error/EOF,  will contain the number of bytes transferred.   | |
| typedef ACE_DEV_Addr | PEER_ADDR | 
| ssize_t | recv_n (void *buf, size_t n, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const | 
| ssize_t | send (const iovec iov[], size_t n) const | 
| Send iovecs via <::writev>.   | |
| ssize_t | recv (iovec iov[], size_t n) const | 
| Recv iovecs via <::readv>.   | |
| ssize_t | send (size_t n,...) const | 
| ssize_t | recv (size_t n,...) const | 
| ssize_t | send (const void *buf, size_t n, ACE_OVERLAPPED *overlapped) const | 
| Send n bytes via Win32 WriteFile using overlapped I/O.   | |
| ssize_t | recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const | 
| Recv n bytes via Win32 ReadFile using overlapped I/O.   | |
| void | dump (void) const | 
| Dump the state of an object.   | |
| int | get_local_addr (ACE_DEV_Addr &) const | 
| Return the local endpoint address.   | |
| int | get_remote_addr (ACE_DEV_Addr &) const | 
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks.   | |
| ACE_DEV_Addr | addr_ | 
| Address of device we are connected to.   | |
Public Member Functions | |
| ACE_DEV_IO (void) | |
| Default constructor.   | |
| ssize_t | send (const void *buf, size_t n) const | 
| send upto n bytes in buf.   | |
| ssize_t | recv (void *buf, size_t n) const | 
| Recv upto n bytes in buf.   | |
| ssize_t | send_n (const void *buf, size_t n) const | 
| Send n bytes, keep trying until n are sent.   | |
Friends | |
| class | ACE_DEV_Connector | 
Definition at line 40 of file DEV_IO.h.
      
  | 
  
| 
 
  | 
  
      
  | 
  
| 
 Default constructor. 
 Definition at line 53 of file DEV_IO.cpp. References ACE_TRACE. 
 00054 {
00055   ACE_TRACE ("ACE_DEV_IO::ACE_DEV_IO");
00056 }
 | 
  
      
  | 
  
| 
 Dump the state of an object. 
 Reimplemented from ACE_DEV. Definition at line 40 of file DEV_IO.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TRACE, addr_, ACE_DEV_Addr::dump(), and LM_DEBUG. 
  | 
  
      
  | 
  
| 
 Return the local endpoint address. 
 Definition at line 20 of file DEV_IO.cpp. References ACE_TRACE, and addr_. 
  | 
  
      
  | 
  
| 
 Return the address of the remotely connected peer (if there is one). Definition at line 32 of file DEV_IO.cpp. References ACE_TRACE, and addr_. 
  | 
  
      
  | 
  ||||||||||||||||
| 
 Recv n bytes via Win32 ReadFile using overlapped I/O. 
 Definition at line 88 of file DEV_IO.inl. References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::read(). 
 00090 {
00091   ACE_TRACE ("ACE_DEV_IO::recv");
00092   return ACE_OS::read (this->get_handle (), (char *) buf, n,
00093                        overlapped);
00094 }
 | 
  
      
  | 
  ||||||||||||
| 
 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 101 of file DEV_IO.cpp. References ACE_NEW_RETURN, ACE_TRACE, ACE_OS::readv(), and ssize_t. 
 00102 {
00103   ACE_TRACE ("ACE_DEV_IO::recv");
00104   va_list argp;
00105   int total_tuples = static_cast<int> (n / 2);
00106   iovec *iovp;
00107 #if defined (ACE_HAS_ALLOCA)
00108   iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00109 #else
00110   ACE_NEW_RETURN (iovp,
00111                   iovec[total_tuples],
00112                   -1);
00113 #endif /* !defined (ACE_HAS_ALLOCA) */
00114 
00115   va_start (argp, n);
00116 
00117   for (int i = 0; i < total_tuples; i++)
00118     {
00119       iovp[i].iov_base = va_arg (argp, char *);
00120       iovp[i].iov_len  = va_arg (argp, int);
00121     }
00122 
00123   ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
00124 #if !defined (ACE_HAS_ALLOCA)
00125   delete [] iovp;
00126 #endif /* !defined (ACE_HAS_ALLOCA) */
00127   va_end (argp);
00128   return result;
00129 }
 | 
  
      
  | 
  ||||||||||||
| 
 Recv iovecs via <::readv>. 
 Definition at line 71 of file DEV_IO.inl. References ACE_TRACE, and ACE_OS::readv(). 
 00072 {
00073   ACE_TRACE ("ACE_DEV_IO::recv");
00074   return ACE_OS::readv (this->get_handle (), iov, static_cast<int> (n));
00075 }
 | 
  
      
  | 
  ||||||||||||
| 
 Recv upto n bytes in buf. 
 Definition at line 57 of file DEV_IO.inl. References ACE_TRACE, and ACE_OS::read(). 
 00058 {
00059   ACE_TRACE ("ACE_DEV_IO::recv");
00060   return ACE_OS::read (this->get_handle (), (char *) buf, n);
00061 }
 | 
  
      
  | 
  ||||||||||||||||||||
| 
 
 Definition at line 27 of file DEV_IO.inl. References ACE_TRACE, ACE::read_n(), and ACE::recv_n(). 
 00031 {
00032   ACE_TRACE ("ACE_DEV_IO::recv_n");
00033 #if defined (ACE_WIN32)
00034   ACE_UNUSED_ARG (timeout);
00035 
00036   return ACE::read_n (this->get_handle (),
00037                       buf,
00038                       n,
00039                       bytes_transferred);
00040 #else
00041   return ACE::recv_n (this->get_handle (),
00042                       buf,
00043                       n,
00044                       timeout,
00045                       bytes_transferred);
00046 #endif /*ACE_WIN32*/
00047 }
 | 
  
      
  | 
  ||||||||||||||||
| 
 Send n bytes via Win32 WriteFile using overlapped I/O. 
 Definition at line 78 of file DEV_IO.inl. References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::write(). 
 00080 {
00081   ACE_TRACE ("ACE_DEV_IO::send");
00082   return ACE_OS::write (this->get_handle (),
00083                         (const char *) buf, n,
00084                         overlapped);
00085 }
 | 
  
      
  | 
  ||||||||||||
| 
 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 64 of file DEV_IO.cpp. References ACE_NEW_RETURN, ACE_TRACE, ssize_t, and ACE_OS::writev(). 
 00065 {
00066   ACE_TRACE ("ACE_DEV_IO::send");
00067   va_list argp;
00068   int total_tuples = static_cast<int> (n / 2);
00069   iovec *iovp;
00070 #if defined (ACE_HAS_ALLOCA)
00071   iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00072 #else
00073   ACE_NEW_RETURN (iovp,
00074                   iovec[total_tuples],
00075                   -1);
00076 #endif /* !defined (ACE_HAS_ALLOCA) */
00077 
00078   va_start (argp, n);
00079 
00080   for (int i = 0; i < total_tuples; i++)
00081     {
00082       iovp[i].iov_base = va_arg (argp, char *);
00083       iovp[i].iov_len  = va_arg (argp, int);
00084     }
00085 
00086   ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
00087 #if !defined (ACE_HAS_ALLOCA)
00088   delete [] iovp;
00089 #endif /* !defined (ACE_HAS_ALLOCA) */
00090   va_end (argp);
00091   return result;
00092 }
 | 
  
      
  | 
  ||||||||||||
| 
 Send iovecs via <::writev>. 
 Definition at line 64 of file DEV_IO.inl. References ACE_TRACE, and ACE_OS::writev(). 
 00065 {
00066   ACE_TRACE ("ACE_DEV_IO::send");
00067   return ACE_OS::writev (this->get_handle (), iov, static_cast<int> (n));
00068 }
 | 
  
      
  | 
  ||||||||||||
| 
 send upto n bytes in buf. 
 Definition at line 50 of file DEV_IO.inl. References ACE_TRACE, and ACE_OS::write(). 
 00051 {
00052   ACE_TRACE ("ACE_DEV_IO::send");
00053   return ACE_OS::write (this->get_handle (), (const char *) buf, n);
00054 }
 | 
  
      
  | 
  ||||||||||||
| 
 Send n bytes, keep trying until n are sent. 
 Definition at line 17 of file DEV_IO.inl. References ACE_TRACE, and ACE::write_n(). 
 00018 {
00019   ACE_TRACE ("ACE_DEV_IO::send_n");
00020   return ACE::write_n (this->get_handle (), buf, n);
00021 }
 | 
  
      
  | 
  
| 
 
  | 
  
      
  | 
  
| 
 Declare the dynamic allocation hooks. 
 Reimplemented from ACE_DEV.  | 
  
      
  | 
  
| 
 Address of device we are connected to. 
 Definition at line 175 of file DEV_IO.h. Referenced by ACE_DEV_Connector::connect(), dump(), get_local_addr(), and get_remote_addr().  | 
  
 
1.3.6