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

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.

Public Types

typedef ACE_DEV_Addr PEER_ADDR

Public Methods

 ACE_DEV_IO (void)
 Default constructor. More...

ssize_t send (const void *buf, size_t n) const
 send upto <n> bytes in <buf>. More...

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

ssize_t send_n (const void *buf, size_t n) const
 Send n bytes, keep trying until n are sent. More...

ssize_t recv_n (void *buf, size_t n) const
 Recv n bytes, keep trying until n are received. More...

ssize_t send (const iovec iov[], size_t n) const
 Send iovecs via <writev>. More...

ssize_t recv (iovec iov[], size_t n) const
 Recv iovecs via <readv>. More...

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

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

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

int get_local_addr (ACE_DEV_Addr &) const
 Return the local endpoint address. More...

int get_remote_addr (ACE_DEV_Addr &) const
 Return the address of the remotely connected peer (if there is one). More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Attributes

ACE_DEV_Addr addr_
 Address of device we are connected to. More...


Friends

class ACE_DEV_Connector

Detailed Description

Read/Write operations on Devices.

Definition at line 33 of file DEV_IO.h.


Member Typedef Documentation

typedef ACE_DEV_Addr ACE_DEV_IO::PEER_ADDR
 

Definition at line 123 of file DEV_IO.h.


Constructor & Destructor Documentation

ACE_DEV_IO::ACE_DEV_IO void   
 

Default constructor.

Definition at line 50 of file DEV_IO.cpp.

References ACE_TRACE.

00051 {
00052   ACE_TRACE ("ACE_DEV_IO::ACE_DEV_IO");
00053 }


Member Function Documentation

void ACE_DEV_IO::dump void    const
 

Dump the state of an object.

Reimplemented from ACE_DEV.

Definition at line 39 of file DEV_IO.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TRACE, addr_, ACE_DEV_Addr::dump, and LM_DEBUG.

00040 {
00041   ACE_TRACE ("ACE_DEV_IO::dump");
00042 
00043   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00044   this->addr_.dump ();
00045   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00046 }

int ACE_DEV_IO::get_local_addr ACE_DEV_Addr   const
 

Return the local endpoint address.

Definition at line 19 of file DEV_IO.cpp.

References ACE_TRACE, and addr_.

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

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 31 of file DEV_IO.cpp.

References ACE_TRACE, and addr_.

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

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

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

Definition at line 65 of file DEV_IO.i.

References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::read.

00067 {
00068   ACE_TRACE ("ACE_DEV_IO::recv");
00069   return ACE_OS::read (this->get_handle (), (char *) buf, n,
00070                        overlapped);
00071 }

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 98 of file DEV_IO.cpp.

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

00099 {
00100   ACE_TRACE ("ACE_DEV_IO::recv");
00101   va_list argp;  
00102   int total_tuples = ACE_static_cast (int, (n / 2));
00103   iovec *iovp;
00104 #if defined (ACE_HAS_ALLOCA)
00105   iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00106 #else 
00107   ACE_NEW_RETURN (iovp,
00108                   iovec[total_tuples],
00109                   -1);
00110 #endif /* !defined (ACE_HAS_ALLOCA) */
00111 
00112   va_start (argp, n);
00113 
00114   for (int i = 0; i < total_tuples; i++)
00115     {
00116       iovp[i].iov_base = va_arg (argp, char *);
00117       iovp[i].iov_len  = va_arg (argp, int);
00118     }
00119 
00120   ssize_t result = ACE_OS::readv (this->get_handle (), iovp, 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_DEV_IO::recv iovec    iov[],
size_t    n
const
 

Recv iovecs via <readv>.

Definition at line 48 of file DEV_IO.i.

References ACE_TRACE, and ACE_OS::readv.

00049 {
00050   ACE_TRACE ("ACE_DEV_IO::recv");
00051   return ACE_OS::readv (this->get_handle (), iov, ACE_static_cast (int, n));
00052 }

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

Recv upto <n> bytes in <buf>.

Definition at line 34 of file DEV_IO.i.

References ACE_TRACE, and ACE_OS::read.

00035 {
00036   ACE_TRACE ("ACE_DEV_IO::recv");
00037   return ACE_OS::read (this->get_handle (), (char *) buf, n);
00038 }

ASYS_INLINE ssize_t ACE_DEV_IO::recv_n void *    buf,
size_t    n
const
 

Recv n bytes, keep trying until n are received.

Definition at line 20 of file DEV_IO.i.

References ACE_TRACE, and ACE::read_n.

00021 {
00022   ACE_TRACE ("ACE_DEV_IO::recv_n");
00023   return ACE::read_n (this->get_handle (), buf, n);
00024 }

ASYS_INLINE ssize_t ACE_DEV_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 55 of file DEV_IO.i.

References ACE_OVERLAPPED, ACE_TRACE, and ACE_OS::write.

00057 {
00058   ACE_TRACE ("ACE_DEV_IO::send");
00059   return ACE_OS::write (this->get_handle (),
00060                         (const char *) buf, n,
00061                         overlapped);
00062 }

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 61 of file DEV_IO.cpp.

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

00062 {
00063   ACE_TRACE ("ACE_DEV_IO::send");
00064   va_list argp;  
00065   int total_tuples = ACE_static_cast (int, (n / 2));
00066   iovec *iovp;
00067 #if defined (ACE_HAS_ALLOCA)
00068   iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00069 #else
00070   ACE_NEW_RETURN (iovp,
00071                   iovec[total_tuples],
00072                   -1);
00073 #endif /* !defined (ACE_HAS_ALLOCA) */
00074 
00075   va_start (argp, n);
00076 
00077   for (int i = 0; i < total_tuples; i++)
00078     {
00079       iovp[i].iov_base = va_arg (argp, char *);
00080       iovp[i].iov_len  = va_arg (argp, int);
00081     }
00082 
00083   ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
00084 #if !defined (ACE_HAS_ALLOCA)
00085   delete [] iovp;
00086 #endif /* !defined (ACE_HAS_ALLOCA) */
00087   va_end (argp);
00088   return result;
00089 }

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

Send iovecs via <writev>.

Definition at line 41 of file DEV_IO.i.

References ACE_TRACE, and ACE_OS::writev.

00042 {
00043   ACE_TRACE ("ACE_DEV_IO::send");
00044   return ACE_OS::writev (this->get_handle (), iov, ACE_static_cast (int, n));
00045 }

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

send upto <n> bytes in <buf>.

Definition at line 27 of file DEV_IO.i.

References ACE_TRACE, and ACE_OS::write.

00028 {
00029   ACE_TRACE ("ACE_DEV_IO::send");
00030   return ACE_OS::write (this->get_handle (), (const char *) buf, n);
00031 }

ASYS_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 10 of file DEV_IO.i.

References ACE_TRACE, and ACE::write_n.

00011 {
00012   ACE_TRACE ("ACE_DEV_IO::send_n");
00013   return ACE::write_n (this->get_handle (), buf, n);
00014 }


Friends And Related Function Documentation

friend class ACE_DEV_Connector [friend]
 

Definition at line 36 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 120 of file DEV_IO.h.

ACE_DEV_Addr ACE_DEV_IO::addr_ [private]
 

Address of device we are connected to.

Definition at line 127 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 Mon Jun 16 12:47:05 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002