Public Member Functions | Protected Attributes

TAO_AV_UDP_Transport Class Reference

A transport abstraction for udp sockets. Uses the ACE_SOCK_Dgram to send the data. More...

#include <UDP.h>

Inheritance diagram for TAO_AV_UDP_Transport:
Inheritance graph
[legend]
Collaboration diagram for TAO_AV_UDP_Transport:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_AV_UDP_Transport (void)
 TAO_AV_UDP_Transport (TAO_AV_UDP_Flow_Handler *handler)
virtual ~TAO_AV_UDP_Transport (void)
virtual int open (ACE_Addr *addr)
virtual int close (void)
virtual int mtu (void)
 Write the complete Message_Block chain to the connection.
virtual ACE_Addrget_peer_addr (void)
virtual int set_remote_address (const ACE_INET_Addr &address)
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.
TAO_AV_UDP_Flow_Handlerhandler (void)

Protected Attributes

TAO_AV_UDP_Flow_Handlerhandler_
ACE_Addraddr_
ACE_INET_Addr peer_addr_

Detailed Description

A transport abstraction for udp sockets. Uses the ACE_SOCK_Dgram to send the data.

Definition at line 48 of file UDP.h.


Constructor & Destructor Documentation

TAO_AV_UDP_Transport::TAO_AV_UDP_Transport ( void   ) 

Definition at line 162 of file UDP.cpp.

  :handler_ (0)
{
}

TAO_AV_UDP_Transport::TAO_AV_UDP_Transport ( TAO_AV_UDP_Flow_Handler handler  ) 

Definition at line 167 of file UDP.cpp.

  :handler_ (handler),
   addr_ (0)
{
}

TAO_AV_UDP_Transport::~TAO_AV_UDP_Transport ( void   )  [virtual]

Definition at line 173 of file UDP.cpp.

{
}


Member Function Documentation

int TAO_AV_UDP_Transport::close ( void   )  [virtual]

Implements TAO_AV_Transport.

Definition at line 191 of file UDP.cpp.

{
  return 0;
}

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

Implements TAO_AV_Transport.

Definition at line 203 of file UDP.cpp.

{
  return &this->peer_addr_;
}

TAO_AV_UDP_Flow_Handler* TAO_AV_UDP_Transport::handler ( void   )  [inline]

Definition at line 98 of file UDP.h.

{ return this->handler_; }

int TAO_AV_UDP_Transport::mtu ( void   )  [virtual]

Write the complete Message_Block chain to the connection.

Implements TAO_AV_Transport.

Definition at line 197 of file UDP.cpp.

{
  return 65535;
}

int TAO_AV_UDP_Transport::open ( ACE_Addr addr  )  [virtual]

Implements TAO_AV_Transport.

Definition at line 185 of file UDP.cpp.

{
  return 0;
}

ssize_t TAO_AV_UDP_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 292 of file UDP.cpp.

{
  return this->handler_->get_socket ()->recv (buf, len,this->peer_addr_);
}

ssize_t TAO_AV_UDP_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 300 of file UDP.cpp.

{
  return this->handler_->get_socket ()->recv (buf,
                                              len,
                                              this->peer_addr_,
                                              flags,
                                              timeout);
}

ssize_t TAO_AV_UDP_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 313 of file UDP.cpp.

{
  return handler_->get_socket ()->recv (iov,this->peer_addr_,0,timeout);
}

ssize_t TAO_AV_UDP_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 281 of file UDP.cpp.

{
  return this->handler_->get_socket ()->send ((const iovec *) iov,
                                              iovcnt,
                                              this->peer_addr_);

}

ssize_t TAO_AV_UDP_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 209 of file UDP.cpp.

{
  // For the most part this was copied from GIOP::send_request and
  // friends.

  iovec iov[ACE_IOV_MAX];
  int iovcnt = 0;
  ssize_t n = 0;
  ssize_t nbytes = 0;

  for (const ACE_Message_Block *i = mblk;
       i != 0;
       i = i->cont ())
    {
      // Make sure there is something to send!
      if (i->length () > 0)
        {
          iov[iovcnt].iov_base = i->rd_ptr ();
          iov[iovcnt].iov_len  = static_cast<u_long> (i->length ());
          iovcnt++;

          // The buffer is full make a OS call.  @@ TODO this should
          // be optimized on a per-platform basis, for instance, some
          // platforms do not implement writev() there we should copy
          // the data into a buffer and call send_n(). In other cases
          // there may be some limits on the size of the iovec, there
          // we should set ACE_IOV_MAX to that limit.
          if (iovcnt == ACE_IOV_MAX)
            {
               n = this->handler_->get_socket ()->send ((const iovec *) iov,
                                                        iovcnt,
                                                        this->peer_addr_);

              if (n < 1)
                return n;

              nbytes += n;
              iovcnt = 0;
            }
        }
    }

  // Check for remaining buffers to be sent!
  if (iovcnt != 0)
    {
      n = this->handler_->get_socket ()->send ((const iovec *) iov,
                                               iovcnt,
                                               this->peer_addr_);

      if (n < 1)
        return n;

      nbytes += n;
    }

  return nbytes;
}

ssize_t TAO_AV_UDP_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 268 of file UDP.cpp.

{
  if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_Transport::send "));
  ACE_TCHAR addr [BUFSIZ];
  this->peer_addr_.addr_to_string (addr,BUFSIZ);
  if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"to %s\n",addr));

  return this->handler_->get_socket ()->send (buf, len,this->peer_addr_);
}

int TAO_AV_UDP_Transport::set_remote_address ( const ACE_INET_Addr address  )  [virtual]

Definition at line 178 of file UDP.cpp.

{
  this->peer_addr_ = address;
  return 0;
}


Member Data Documentation

Definition at line 102 of file UDP.h.

Definition at line 101 of file UDP.h.

Definition at line 103 of file UDP.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines