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

ACE_FILE_IO Class Reference

Read/Write operations on Files. More...

#include <FILE_IO.h>

Inheritance diagram for ACE_FILE_IO:

Inheritance graph
[legend]
Collaboration diagram for ACE_FILE_IO:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_FILE_Addr PEER_ADDR

Public Methods

 ACE_FILE_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 send_n (const ACE_Message_Block *message_block, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0)
 Send all the <message_block>s chained through their <next> and <cont> pointers. This call uses the underlying OS gather-write operation to reduce the domain-crossing penalty. 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[], int n) const
 Send iovecs via <writev>. More...

ssize_t recv (iovec iov[], int 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...

ssize_t sendv (const iovec iov[], int n) const
 Send an <iovec> of size <n> to the file. More...

ssize_t recvv (iovec *io_vec)
ssize_t sendv_n (const iovec iov[], int n) const
 Send an <iovec> of size <n> to the file. Will block until all bytes are sent or an error occurs. More...

ssize_t recvv_n (iovec iov[], int n) const
 Receive an <iovec> of size <n> to the file. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Friends

class ACE_FILE_Connector

Detailed Description

Read/Write operations on Files.

Definition at line 36 of file FILE_IO.h.


Member Typedef Documentation

typedef ACE_FILE_Addr ACE_FILE_IO::PEER_ADDR
 

Definition at line 152 of file FILE_IO.h.


Constructor & Destructor Documentation

ACE_FILE_IO::ACE_FILE_IO void   
 

Default constructor.

Definition at line 28 of file FILE_IO.cpp.

References ACE_TRACE.

00029 {
00030   ACE_TRACE ("ACE_FILE_IO::ACE_FILE_IO");
00031 }


Member Function Documentation

void ACE_FILE_IO::dump void    const
 

Dump the state of an object.

Reimplemented from ACE_FILE.

Definition at line 17 of file FILE_IO.cpp.

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

00018 {
00019   ACE_TRACE ("ACE_FILE_IO::dump");
00020 
00021   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00022   this->addr_.dump ();
00023   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00024 }

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

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

ssize_t ACE_FILE_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 78 of file FILE_IO.cpp.

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

00079 {
00080   ACE_TRACE ("ACE_FILE_IO::recv");
00081   va_list argp;  
00082   int total_tuples = ACE_static_cast (int, (n / 2));
00083   iovec *iovp;
00084 #if defined (ACE_HAS_ALLOCA)
00085   iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00086 #else
00087   ACE_NEW_RETURN (iovp,
00088                   iovec[total_tuples],
00089                   -1);
00090 #endif /* !defined (ACE_HAS_ALLOCA) */
00091 
00092   va_start (argp, n);
00093 
00094   for (int i = 0; i < total_tuples; i++)
00095     {
00096       iovp[i].iov_base = va_arg (argp, char *);
00097       iovp[i].iov_len  = va_arg (argp, int);
00098     }
00099 
00100   ssize_t result = ACE_OS::readv (this->get_handle (),
00101                                   iovp, 
00102                                   total_tuples);
00103 #if !defined (ACE_HAS_ALLOCA)
00104   delete [] iovp;
00105 #endif /* !defined (ACE_HAS_ALLOCA) */
00106   va_end (argp);
00107   return result;
00108 }

ASYS_INLINE ssize_t ACE_FILE_IO::recv iovec    iov[],
int    n
const
 

Recv iovecs via <readv>.

Definition at line 91 of file FILE_IO.i.

References ACE_TRACE, and ACE_OS::readv.

00092 {
00093   ACE_TRACE ("ACE_FILE_IO::recv");
00094   return ACE_OS::readv (this->get_handle (), iov, n);
00095 }

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

Recv upto <n> bytes in <buf>.

Definition at line 77 of file FILE_IO.i.

References ACE_TRACE, and ACE_OS::read.

00078 {
00079   ACE_TRACE ("ACE_FILE_IO::recv");
00080   return ACE_OS::read (this->get_handle (), (char *) buf, n);
00081 }

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

Recv n bytes, keep trying until n are received.

Definition at line 63 of file FILE_IO.i.

References ACE_TRACE, and ACE::read_n.

Referenced by recvv.

00064 {
00065   ACE_TRACE ("ACE_FILE_IO::recv_n");
00066   return ACE::read_n (this->get_handle (), buf, n);
00067 }

ssize_t ACE_FILE_IO::recvv iovec   io_vec
 

Allows a client to read from a file without having to provide a buffer to read. This method determines how much data is in the file, 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 116 of file FILE_IO.cpp.

References ACE_NEW_RETURN, ACE_TRACE, ACE_OS::filesize, iovec::iov_base, iovec::iov_len, and recv_n.

00117 {
00118   ACE_TRACE ("ACE_FILE_IO::recvv");
00119 
00120   io_vec->iov_base = 0;
00121   long length = ACE_OS::filesize (this->get_handle ());
00122 
00123   if (length > 0)
00124     {
00125       ACE_NEW_RETURN (io_vec->iov_base,
00126                       char[length],
00127                       -1);
00128       io_vec->iov_len = this->recv_n (io_vec->iov_base,
00129                                       length);
00130       return io_vec->iov_len;
00131     }
00132   else
00133     return length;
00134 }

ASYS_INLINE ssize_t ACE_FILE_IO::recvv_n iovec    iov[],
int    n
const
 

Receive an <iovec> of size <n> to the file.

Definition at line 30 of file FILE_IO.i.

References ACE_TRACE, and ACE_OS::readv.

00031 {
00032   ACE_TRACE ("ACE_FILE_IO::recvv_n");
00033   // @@ Carlos, can you please update this to call the
00034   // new ACE::recvv_n() method that you write?
00035   return ACE_OS::readv (this->get_handle (),
00036                         iov,
00037                         n);
00038 }

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

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

ssize_t ACE_FILE_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 39 of file FILE_IO.cpp.

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

00040 {
00041   ACE_TRACE ("ACE_FILE_IO::send");
00042   va_list argp;  
00043   int  total_tuples = (ACE_static_cast (int, n)) / 2;
00044   iovec *iovp;
00045 #if defined (ACE_HAS_ALLOCA)
00046   iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00047 #else
00048   ACE_NEW_RETURN (iovp,
00049                   iovec[total_tuples],
00050                   -1);
00051 #endif /* !defined (ACE_HAS_ALLOCA) */
00052 
00053   va_start (argp, n);
00054 
00055   for (int i = 0; i < total_tuples; i++)
00056     {
00057       iovp[i].iov_base = va_arg (argp, char *);
00058       iovp[i].iov_len  = va_arg (argp, int);
00059     }
00060 
00061   ssize_t result = ACE_OS::writev (this->get_handle (), 
00062                                    iovp,
00063                                    total_tuples);
00064 #if !defined (ACE_HAS_ALLOCA)
00065   delete [] iovp;
00066 #endif /* !defined (ACE_HAS_ALLOCA) */
00067   va_end (argp);
00068   return result;
00069 }

ASYS_INLINE ssize_t ACE_FILE_IO::send const iovec    iov[],
int    n
const
 

Send iovecs via <writev>.

Definition at line 84 of file FILE_IO.i.

References ACE_TRACE, and ACE_OS::writev.

00085 {
00086   ACE_TRACE ("ACE_FILE_IO::send");
00087   return ACE_OS::writev (this->get_handle (), iov, n);
00088 }

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

send upto <n> bytes in <buf>.

Definition at line 70 of file FILE_IO.i.

References ACE_TRACE, and ACE_OS::write.

00071 {
00072   ACE_TRACE ("ACE_FILE_IO::send");
00073   return ACE_OS::write (this->get_handle (), (const char *) buf, n);
00074 }

ASYS_INLINE ssize_t ACE_FILE_IO::send_n const ACE_Message_Block   message_block,
const ACE_Time_Value   timeout = 0,
size_t *    bytes_transferred = 0
 

Send all the <message_block>s chained through their <next> and <cont> pointers. This call uses the underlying OS gather-write operation to reduce the domain-crossing penalty.

Definition at line 16 of file FILE_IO.i.

References ACE_TRACE, and ACE::write_n.

00019 {
00020   ACE_TRACE ("ACE_FILE_IO::send_n");
00021   ACE_UNUSED_ARG (timeout);
00022   return ACE::write_n (this->get_handle (),
00023                       message_block,
00024                       bytes_transferred);
00025 }

ASYS_INLINE ssize_t ACE_FILE_IO::send_n const void *    buf,
size_t    n
const
 

Send n bytes, keep trying until n are sent.

Definition at line 53 of file FILE_IO.i.

References ACE_TRACE, and ACE::write_n.

00054 {
00055   ACE_TRACE ("ACE_FILE_IO::send_n");
00056   return ACE::write_n (this->get_handle (), buf, n);
00057 }

ASYS_INLINE ssize_t ACE_FILE_IO::sendv const iovec    iov[],
int    n
const
 

Send an <iovec> of size <n> to the file.

Definition at line 43 of file FILE_IO.i.

References ACE_TRACE, and ACE_OS::writev.

00044 {
00045   ACE_TRACE ("ACE_FILE_IO::sendv");
00046   return ACE_OS::writev (this->get_handle (), iov, n);
00047 }

ASYS_INLINE ssize_t ACE_FILE_IO::sendv_n const iovec    iov[],
int    n
const
 

Send an <iovec> of size <n> to the file. Will block until all bytes are sent or an error occurs.

Definition at line 7 of file FILE_IO.i.

References ACE_TRACE, and ACE::writev_n.

00008 {
00009   ACE_TRACE ("ACE_FILE_IO::sendv_n");
00010   return ACE::writev_n (this->get_handle (),
00011                         iov,
00012                         n);
00013 }


Friends And Related Function Documentation

friend class ACE_FILE_Connector [friend]
 

Definition at line 39 of file FILE_IO.h.


Member Data Documentation

ACE_FILE_IO::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_FILE.

Definition at line 149 of file FILE_IO.h.


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