TAO_AV_UDP_MCast_Transport Class Reference

A transport abstraction for Multicast dgram sockets. Uses the ACE_SOCK_Dgram_Mcast to send data. More...

#include <MCast.h>

Inheritance diagram for TAO_AV_UDP_MCast_Transport:

Inheritance graph
[legend]
Collaboration diagram for TAO_AV_UDP_MCast_Transport:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_AV_UDP_MCast_Transport (void)
 TAO_AV_UDP_MCast_Transport (TAO_AV_UDP_MCast_Flow_Handler *handler)
virtual ~TAO_AV_UDP_MCast_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)
 Write the complete Message_Block chain to the connection.
virtual ACE_Addrget_local_addr (void)
virtual ssize_t send (const ACE_Message_Block *mblk, ACE_Time_Value *s=0)
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_UDP_MCast_Flow_Handlerhandler_
ACE_INET_Addr peer_addr_
ACE_INET_Addr local_addr_

Detailed Description

A transport abstraction for Multicast dgram sockets. Uses the ACE_SOCK_Dgram_Mcast to send data.

Definition at line 32 of file MCast.h.


Constructor & Destructor Documentation

TAO_AV_UDP_MCast_Transport::TAO_AV_UDP_MCast_Transport ( void   ) 

Definition at line 63 of file MCast.cpp.

00064   :handler_ (0)
00065 {
00066 }

TAO_AV_UDP_MCast_Transport::TAO_AV_UDP_MCast_Transport ( TAO_AV_UDP_MCast_Flow_Handler handler  ) 

Definition at line 68 of file MCast.cpp.

00069   :handler_ (handler)
00070 {
00071 }

TAO_AV_UDP_MCast_Transport::~TAO_AV_UDP_MCast_Transport ( void   )  [virtual]

Definition at line 73 of file MCast.cpp.

00074 {
00075 }


Member Function Documentation

int TAO_AV_UDP_MCast_Transport::close ( void   )  [virtual]

Implements TAO_AV_Transport.

Definition at line 84 of file MCast.cpp.

00085 {
00086   return 0;
00087 }

ACE_Addr * TAO_AV_UDP_MCast_Transport::get_local_addr ( void   )  [virtual]

Reimplemented from TAO_AV_Transport.

Definition at line 97 of file MCast.cpp.

References ACE_SOCK::get_local_addr(), TAO_AV_UDP_MCast_Flow_Handler::get_mcast_socket(), handler_, and local_addr_.

00098 {
00099   this->handler_->get_mcast_socket ()->get_local_addr (this->local_addr_);
00100   return &this->local_addr_;
00101 }

ACE_Addr * TAO_AV_UDP_MCast_Transport::get_peer_addr ( void   )  [virtual]

Write the complete Message_Block chain to the connection.

Implements TAO_AV_Transport.

Definition at line 91 of file MCast.cpp.

References peer_addr_.

00092 {
00093   return &this->peer_addr_;
00094 }

int TAO_AV_UDP_MCast_Transport::mtu ( void   )  [virtual]

Write the complete Message_Block chain to the connection.

Implements TAO_AV_Transport.

Definition at line 185 of file MCast.cpp.

References ACE_MAX_DGRAM_SIZE.

00186 {
00187   return ACE_MAX_DGRAM_SIZE;
00188 }

int TAO_AV_UDP_MCast_Transport::open ( ACE_Addr address  )  [virtual]

Implements TAO_AV_Transport.

Definition at line 78 of file MCast.cpp.

00079 {
00080   return 0;
00081 }

ssize_t TAO_AV_UDP_MCast_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 213 of file MCast.cpp.

References TAO_AV_UDP_MCast_Flow_Handler::get_mcast_socket(), handler_, and ACE_SOCK_Dgram::recv().

00216 {
00217   return handler_->get_mcast_socket ()->recv (iov,this->peer_addr_,0,timeout);
00218 }

ssize_t TAO_AV_UDP_MCast_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 200 of file MCast.cpp.

References TAO_AV_UDP_MCast_Flow_Handler::get_mcast_socket(), handler_, and ACE_SOCK_Dgram::recv().

00204 {
00205   return this->handler_->get_mcast_socket ()->recv (buf,
00206                                                     len,
00207                                                     this->peer_addr_,
00208                                                     flags,
00209                                                     timeout);
00210 }

ssize_t TAO_AV_UDP_MCast_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 192 of file MCast.cpp.

References TAO_AV_UDP_MCast_Flow_Handler::get_mcast_socket(), handler_, and ACE_SOCK_Dgram::recv().

00195 {
00196   return this->handler_->get_mcast_socket ()->recv (buf, len,this->peer_addr_);
00197 }

ssize_t TAO_AV_UDP_MCast_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 174 of file MCast.cpp.

References TAO_AV_UDP_MCast_Flow_Handler::get_mcast_socket(), handler_, and ACE_SOCK_Dgram_Mcast::send().

00177 {
00178   return this->handler_->get_mcast_socket ()->send (iov,
00179                                                     iovcnt,
00180                                                     0);
00181 
00182 }

ssize_t TAO_AV_UDP_MCast_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 160 of file MCast.cpp.

References TAO_AV_UDP_MCast_Flow_Handler::get_mcast_socket(), handler_, and ACE_SOCK_Dgram_Mcast::send().

00163 {
00164 //   if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_MCast_Transport::send "));
00165 //   char addr [BUFSIZ];
00166 //   this->peer_addr_.addr_to_string (addr,BUFSIZ);
00167 //   if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"to %s\n",addr));
00168 
00169   return this->handler_->get_mcast_socket ()->send (buf, len);
00170 
00171 }

ssize_t TAO_AV_UDP_MCast_Transport::send ( const ACE_Message_Block mblk,
ACE_Time_Value s = 0 
) [virtual]

Implements TAO_AV_Transport.

Definition at line 104 of file MCast.cpp.

References ACE_IOV_MAX, ACE_Message_Block::cont(), TAO_AV_UDP_MCast_Flow_Handler::get_mcast_socket(), handler_, and ACE_SOCK_Dgram_Mcast::send().

00105 {
00106   // For the most part this was copied from GIOP::send_request and
00107   // friends.
00108 
00109   iovec iov[ACE_IOV_MAX];
00110   int iovcnt = 0;
00111   ssize_t n = 0;
00112   ssize_t nbytes = 0;
00113 
00114   for (const ACE_Message_Block *i = mblk;
00115        i != 0;
00116        i = i->cont ())
00117     {
00118       // Make sure there is something to send!
00119       if (i->length () > 0)
00120         {
00121           iov[iovcnt].iov_base = i->rd_ptr ();
00122           iov[iovcnt].iov_len  = static_cast<u_long> (i->length ());
00123           iovcnt++;
00124 
00125           // The buffer is full make a OS call.  @@ TODO this should
00126           // be optimized on a per-platform basis, for instance, some
00127           // platforms do not implement writev() there we should copy
00128           // the data into a buffer and call send_n(). In other cases
00129           // there may be some limits on the size of the iovec, there
00130           // we should set ACE_IOV_MAX to that limit.
00131           if (iovcnt == ACE_IOV_MAX)
00132             {
00133               n = this->handler_->get_mcast_socket ()->send ((const iovec *) iov,
00134                                                              iovcnt);
00135 
00136               if (n < 1)
00137                 return n;
00138 
00139               nbytes += n;
00140               iovcnt = 0;
00141             }
00142         }
00143     }
00144 
00145   // Check for remaining buffers to be sent!
00146   if (iovcnt != 0)
00147     {
00148       n = this->handler_->get_mcast_socket ()->send ((const iovec *) iov,
00149                                                      iovcnt);
00150       if (n < 1)
00151         return n;
00152 
00153       nbytes += n;
00154     }
00155 
00156   return nbytes;
00157 }


Member Data Documentation

TAO_AV_UDP_MCast_Flow_Handler* TAO_AV_UDP_MCast_Transport::handler_ [protected]

Definition at line 81 of file MCast.h.

Referenced by get_local_addr(), recv(), and send().

ACE_INET_Addr TAO_AV_UDP_MCast_Transport::local_addr_ [protected]

Definition at line 83 of file MCast.h.

Referenced by get_local_addr().

ACE_INET_Addr TAO_AV_UDP_MCast_Transport::peer_addr_ [protected]

Definition at line 82 of file MCast.h.

Referenced by get_peer_addr().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:48:07 2010 for TAO_AV by  doxygen 1.4.7