TAO_AV_TCP_Transport Class Reference

A transport abstraction for socket streams. Uses the ACE_SOCK_Stream to send the data. More...

#include <TCP.h>

Inheritance diagram for TAO_AV_TCP_Transport:

Inheritance graph
[legend]
Collaboration diagram for TAO_AV_TCP_Transport:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_AV_TCP_Transport (void)
 TAO_AV_TCP_Transport (TAO_AV_TCP_Flow_Handler *handler)
virtual ~TAO_AV_TCP_Transport (void)
virtual int open (ACE_Addr *address)
virtual int close (void)
virtual int mtu (void)
 Write the complete Message_Block chain to the connection.

virtual ACE_Addrget_peer_addr (void)
virtual ssize_t send (const ACE_Message_Block *mblk, ACE_Time_Value *s=0)
 Write the complete Message_Block chain to the connection.

virtual ssize_t send (const char *buf, size_t len, ACE_Time_Value *s=0)
 Write the contents of the buffer of length len to the connection.

virtual ssize_t send (const iovec *iov, int iovcnt, ACE_Time_Value *s=0)
 Write the contents of iovcnt iovec's to the connection.

virtual ssize_t recv (char *buf, size_t len, ACE_Time_Value *s=0)
 Read len bytes from into buf.

virtual ssize_t recv (char *buf, size_t len, int flags, ACE_Time_Value *s=0)
 Read len bytes from into buf using flags.

virtual ssize_t recv (iovec *iov, int iovcnt, ACE_Time_Value *s=0)
 Read received data into the iovec buffers.


Protected Attributes

TAO_AV_TCP_Flow_Handlerhandler_

Detailed Description

A transport abstraction for socket streams. Uses the ACE_SOCK_Stream to send the data.

Definition at line 49 of file TCP.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_AV_TCP_Transport::TAO_AV_TCP_Transport void   ) 
 

Definition at line 15 of file TCP.cpp.

00016   :handler_ (0)
00017 {
00018 }

TAO_AV_TCP_Transport::TAO_AV_TCP_Transport TAO_AV_TCP_Flow_Handler handler  ) 
 

Definition at line 20 of file TCP.cpp.

00021   :handler_ (handler)
00022 {
00023 }

TAO_AV_TCP_Transport::~TAO_AV_TCP_Transport void   )  [virtual]
 

Definition at line 25 of file TCP.cpp.

00026 {
00027 }


Member Function Documentation

int TAO_AV_TCP_Transport::close void   )  [virtual]
 

Implements TAO_AV_Transport.

Definition at line 36 of file TCP.cpp.

00037 {
00038   return 0;
00039 }

ACE_Addr * TAO_AV_TCP_Transport::get_peer_addr void   )  [virtual]
 

Implements TAO_AV_Transport.

Definition at line 48 of file TCP.cpp.

00049 {
00050   return 0;
00051 }

int TAO_AV_TCP_Transport::mtu void   )  [virtual]
 

Write the complete Message_Block chain to the connection.

Implements TAO_AV_Transport.

Definition at line 42 of file TCP.cpp.

00043 {
00044   return -1;
00045 }

int TAO_AV_TCP_Transport::open ACE_Addr address  )  [virtual]
 

Implements TAO_AV_Transport.

Definition at line 30 of file TCP.cpp.

00031 {
00032   return 0;
00033 }

ssize_t TAO_AV_TCP_Transport::recv iovec iov,
int  iovcnt,
ACE_Time_Value s = 0
[virtual]
 

Read received data into the iovec buffers.

Implements TAO_AV_Transport.

Definition at line 145 of file TCP.cpp.

References ACE_Svc_Handler< ACE_SOCK_STREAM, ACE_NULL_SYNCH >::peer().

00148 {
00149   return handler_->peer ().recvv_n (iov, iovcnt);
00150 }

ssize_t TAO_AV_TCP_Transport::recv char *  buf,
size_t  len,
int  flags,
ACE_Time_Value s = 0
[virtual]
 

Read len bytes from into buf using flags.

Implements TAO_AV_Transport.

Definition at line 134 of file TCP.cpp.

References ACE_Svc_Handler< ACE_SOCK_STREAM, ACE_NULL_SYNCH >::peer().

00138 {
00139   return this->handler_->peer ().recv (buf,
00140                                        len,
00141                                        flags);
00142 }

ssize_t TAO_AV_TCP_Transport::recv char *  buf,
size_t  len,
ACE_Time_Value s = 0
[virtual]
 

Read len bytes from into buf.

Implements TAO_AV_Transport.

Definition at line 126 of file TCP.cpp.

References ACE_Svc_Handler< ACE_SOCK_STREAM, ACE_NULL_SYNCH >::peer().

00129 {
00130   return this->handler_->peer ().recv (buf, len);
00131 }

ssize_t TAO_AV_TCP_Transport::send const iovec iov,
int  iovcnt,
ACE_Time_Value s = 0
[virtual]
 

Write the contents of iovcnt iovec's to the connection.

Implements TAO_AV_Transport.

Definition at line 117 of file TCP.cpp.

References ACE_Svc_Handler< ACE_SOCK_STREAM, ACE_NULL_SYNCH >::peer().

00120 {
00121   return this->handler_->peer ().sendv_n ((const iovec *) iov,
00122                                           iovcnt);
00123 }

ssize_t TAO_AV_TCP_Transport::send const char *  buf,
size_t  len,
ACE_Time_Value s = 0
[virtual]
 

Write the contents of the buffer of length len to the connection.

Implements TAO_AV_Transport.

Definition at line 109 of file TCP.cpp.

References ACE_Svc_Handler< ACE_SOCK_STREAM, ACE_NULL_SYNCH >::peer().

00112 {
00113   return this->handler_->peer ().send_n (buf, len);
00114 }

ssize_t TAO_AV_TCP_Transport::send const ACE_Message_Block mblk,
ACE_Time_Value s = 0
[virtual]
 

Write the complete Message_Block chain to the connection.

Implements TAO_AV_Transport.

Definition at line 54 of file TCP.cpp.

References ACE_IOV_MAX, ACE_Message_Block::cont(), iovec::iov_base, iovec::iov_len, ACE_Message_Block::length(), ACE_Svc_Handler< ACE_SOCK_STREAM, ACE_NULL_SYNCH >::peer(), ACE_Message_Block::rd_ptr(), and ssize_t.

00055 {
00056   // For the most part this was copied from GIOP::send_request and
00057   // friends.
00058 
00059   iovec iov[ACE_IOV_MAX];
00060   int iovcnt = 0;
00061   ssize_t n = 0;
00062   ssize_t nbytes = 0;
00063 
00064   for (const ACE_Message_Block *i = mblk;
00065        i != 0;
00066        i = i->cont ())
00067     {
00068       // Make sure there is something to send!
00069       if (i->length () > 0)
00070         {
00071           iov[iovcnt].iov_base = i->rd_ptr ();
00072           iov[iovcnt].iov_len  = static_cast<u_long> (i->length ());
00073           iovcnt++;
00074 
00075           // The buffer is full make a OS call.  @@ TODO this should
00076           // be optimized on a per-platform basis, for instance, some
00077           // platforms do not implement writev() there we should copy
00078           // the data into a buffer and call send_n(). In other cases
00079           // there may be some limits on the size of the iovec, there
00080           // we should set ACE_IOV_MAX to that limit.
00081           if (iovcnt == ACE_IOV_MAX)
00082             {
00083               n = this->handler_->peer ().sendv_n ((const iovec *) iov,
00084                                                    iovcnt);
00085               if (n < 1)
00086                 return n;
00087 
00088               nbytes += n;
00089               iovcnt = 0;
00090             }
00091         }
00092     }
00093 
00094   // Check for remaining buffers to be sent!
00095   if (iovcnt != 0)
00096     {
00097       n = this->handler_->peer ().sendv_n ((const iovec *) iov,
00098                                            iovcnt);
00099       if (n < 1)
00100         return n;
00101 
00102       nbytes += n;
00103     }
00104 
00105   return nbytes;
00106 }


Member Data Documentation

TAO_AV_TCP_Flow_Handler* TAO_AV_TCP_Transport::handler_ [protected]
 

Definition at line 98 of file TCP.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:48:02 2006 for TAO_AV by doxygen 1.3.6