ACE_DEV_IO Class Reference

Read/Write operations on Devices. More...

#include <DEV_IO.h>

Inheritance diagram for ACE_DEV_IO:

Inheritance graph
[legend]
Collaboration diagram for ACE_DEV_IO:

Collaboration graph
[legend]
List of all members.

I/O operations

Notes on common parameters:

is the buffer to write from or receive into.

is the number of bytes to transfer.

The parameter in the following methods indicates how long to blocking trying to transfer data. If == 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 != 0, the call will wait until the relative time specified in * 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. 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 complete transfer, the number of bytes transferred is returned.
  • On timeout, -1 is returned, errno == ETIME.
  • On error, -1 is returned, errno is set to appropriate error.
  • On EOF, 0 is returned, errno is irrelevant.

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 bytes via Win32 WriteFile using overlapped I/O.

ssize_t recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const
 Recv 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 bytes in .

ssize_t recv (void *buf, size_t n) const
 Recv upto bytes in .

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

Detailed Description

Read/Write operations on Devices.

Definition at line 40 of file DEV_IO.h.


Member Typedef Documentation

typedef ACE_DEV_Addr ACE_DEV_IO::PEER_ADDR
 

Definition at line 171 of file DEV_IO.h.


Constructor & Destructor Documentation

ACE_DEV_IO::ACE_DEV_IO void   ) 
 

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 }


Member Function Documentation

void ACE_DEV_IO::dump void   )  const
 

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.

00041 {
00042 #if defined (ACE_HAS_DUMP)
00043   ACE_TRACE ("ACE_DEV_IO::dump");
00044 
00045   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00046   this->addr_.dump ();
00047   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00048 #endif /* ACE_HAS_DUMP */
00049 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_DEV_IO::get_local_addr ACE_DEV_Addr  )  const
 

Return the local endpoint address.

Definition at line 20 of file DEV_IO.cpp.

References ACE_TRACE, and addr_.

00021 {
00022   ACE_TRACE ("ACE_DEV_IO::get_local_addr");
00023 
00024   addr = this->addr_;
00025   return 0;
00026 }

int ACE_DEV_IO::get_remote_addr ACE_DEV_Addr  )  const
 

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_.

00033 {
00034   ACE_TRACE ("ACE_DEV_IO::get_remote_addr");
00035   addr = this->addr_;
00036   return 0;
00037 }

ACE_INLINE ssize_t ACE_DEV_IO::recv void *  buf,
size_t  n,
ACE_OVERLAPPED overlapped
const
 

Recv 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 }

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

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, iovec::iov_base, iovec::iov_len, 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 }

ACE_INLINE ssize_t ACE_DEV_IO::recv iovec  iov[],
size_t  n
const
 

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 }

ACE_INLINE ssize_t ACE_DEV_IO::recv void *  buf,
size_t  n
const
 

Recv upto bytes in .

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 }

ACE_INLINE ssize_t ACE_DEV_IO::recv_n void *  buf,
size_t  n,
const ACE_Time_Value timeout = 0,
size_t *  bytes_transferred = 0
const
 

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 }

ACE_INLINE ssize_t ACE_DEV_IO::send const void *  buf,
size_t  n,
ACE_OVERLAPPED overlapped
const
 

Send 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 }

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

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, iovec::iov_base, iovec::iov_len, 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 }

ACE_INLINE ssize_t ACE_DEV_IO::send const iovec  iov[],
size_t  n
const
 

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 }

ACE_INLINE ssize_t ACE_DEV_IO::send const void *  buf,
size_t  n
const
 

send upto bytes in .

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 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ssize_t ACE_DEV_IO::send_n const void *  buf,
size_t  n
const
 

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 }


Friends And Related Function Documentation

friend class ACE_DEV_Connector [friend]
 

Definition at line 43 of file DEV_IO.h.


Member Data Documentation

ACE_DEV_IO::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_DEV.

Definition at line 168 of file DEV_IO.h.

ACE_DEV_Addr ACE_DEV_IO::addr_ [private]
 

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().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:21:23 2006 for ACE by doxygen 1.3.6