TAO_ECG_UDP_Out_Endpoint Class Reference

Maintains information about an outgoing endpoint. More...

#include <ECG_UDP_Out_Endpoint.h>

Collaboration diagram for TAO_ECG_UDP_Out_Endpoint:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_ECG_UDP_Out_Endpoint (void)
 Constructor.

 ~TAO_ECG_UDP_Out_Endpoint (void)
 Constructor.

 TAO_ECG_UDP_Out_Endpoint (const TAO_ECG_UDP_Out_Endpoint &rhs)
 Copy Constructor.

TAO_ECG_UDP_Out_Endpointoperator= (const TAO_ECG_UDP_Out_Endpoint &rhs)
 Assignment operator.

ACE_SOCK_Dgramdgram (void)
CORBA::ULong next_request_id (void)
 Obtain the next request id.

CORBA::Boolean is_loopback (const ACE_INET_Addr &from)

Private Attributes

ACE_Atomic_Op< TAO_SYNCH_MUTEX,
CORBA::ULong
request_id_generator_
 The request id....

ACE_SOCK_Dgram dgram_
 The datagram....

u_short port_number_
size_t if_count_
ACE_INET_Addrifs_

Detailed Description

Maintains information about an outgoing endpoint.

UDP senders can share a single endpoint to send UDP packets, but there is more state associated with this endpoint than its datagram SAP; for instance we need to keep track of the request id.

Definition at line 46 of file ECG_UDP_Out_Endpoint.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_ECG_UDP_Out_Endpoint::TAO_ECG_UDP_Out_Endpoint void   ) 
 

Constructor.

Definition at line 8 of file ECG_UDP_Out_Endpoint.i.

00009   : port_number_ (0),
00010     if_count_ (0),
00011     ifs_ (0)
00012 {
00013 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_ECG_UDP_Out_Endpoint::~TAO_ECG_UDP_Out_Endpoint void   ) 
 

Constructor.

Definition at line 15 of file ECG_UDP_Out_Endpoint.cpp.

References ACE_SOCK::close(), and ifs_.

00016 {
00017   this->dgram_.close ();
00018 
00019   delete [] this->ifs_;
00020 }

ACE_INLINE TAO_ECG_UDP_Out_Endpoint::TAO_ECG_UDP_Out_Endpoint const TAO_ECG_UDP_Out_Endpoint rhs  ) 
 

Copy Constructor.

Definition at line 16 of file ECG_UDP_Out_Endpoint.i.

00018   : port_number_ (0),
00019     if_count_ (0),
00020     ifs_ (0)
00021 {
00022   *this = rhs;
00023 }


Member Function Documentation

ACE_INLINE ACE_SOCK_Dgram & TAO_ECG_UDP_Out_Endpoint::dgram void   ) 
 

Obtain the datagram associated with this endpoint. Clients of this class must open, and register (if necessary) this datagram.

Definition at line 26 of file ECG_UDP_Out_Endpoint.i.

Referenced by is_loopback().

00027 {
00028   return this->dgram_;
00029 }

CORBA::Boolean TAO_ECG_UDP_Out_Endpoint::is_loopback const ACE_INET_Addr from  ) 
 

The endpoint can detect if a data-gram was sent by itself, this is useful to ignore or remove messages sent by the same process.

Definition at line 23 of file ECG_UDP_Out_Endpoint.cpp.

References dgram(), ACE_INET_Addr::get_ip_address(), ACE::get_ip_interfaces(), ACE_SOCK::get_local_addr(), ACE_INET_Addr::get_port_number(), if_count_, ifs_, and port_number_.

00024 {
00025   if (this->port_number_ == 0)
00026     {
00027       // Cache the port number...
00028       ACE_INET_Addr local_addr;
00029       if (this->dgram ().get_local_addr (local_addr) == -1)
00030         return 0;
00031       this->port_number_ = local_addr.get_port_number ();
00032     }
00033 
00034   // Most of the time the port number is enough to determine if the
00035   // message is remote, only when the local port number and the remote
00036   // port number match we have to look at the local ip addresses.
00037   if (from.get_port_number () != this->port_number_)
00038     return 0;
00039 
00040   if (this->ifs_ == 0)
00041     {
00042       ACE::get_ip_interfaces (this->if_count_, this->ifs_);
00043     }
00044 
00045   for (ACE_INET_Addr* i = this->ifs_;
00046        i != this->ifs_ + this->if_count_;
00047        ++i)
00048     {
00049       if ((*i).get_ip_address () == from.get_ip_address ())
00050         return 1;
00051     }
00052   return 0;
00053 }

ACE_INLINE CORBA::ULong TAO_ECG_UDP_Out_Endpoint::next_request_id void   ) 
 

Obtain the next request id.

Definition at line 32 of file ECG_UDP_Out_Endpoint.i.

00033 {
00034   return this->request_id_generator_++;
00035 }

TAO_ECG_UDP_Out_Endpoint & TAO_ECG_UDP_Out_Endpoint::operator= const TAO_ECG_UDP_Out_Endpoint rhs  ) 
 

Assignment operator.

Definition at line 56 of file ECG_UDP_Out_Endpoint.cpp.

References ACE_NEW_RETURN, dgram_, if_count_, ifs_, port_number_, and request_id_generator_.

00057 {
00058   if (this != &rhs)
00059     {
00060       this->request_id_generator_ = rhs.request_id_generator_;
00061       this->dgram_ = rhs.dgram_;
00062       this->port_number_ = rhs.port_number_;
00063       this->if_count_ = rhs.if_count_;
00064 
00065       delete [] this->ifs_;
00066       this->ifs_ = 0;
00067 
00068       if (this->if_count_ != 0)
00069         {
00070           ACE_NEW_RETURN (this->ifs_,
00071                           ACE_INET_Addr [this->if_count_],
00072                           *this);
00073           for(size_t i = 0; i < this->if_count_; ++i)
00074             {
00075               this->ifs_[i] = rhs.ifs_[i];
00076             }
00077         }
00078     }
00079 
00080   return *this;
00081 }


Member Data Documentation

ACE_SOCK_Dgram TAO_ECG_UDP_Out_Endpoint::dgram_ [private]
 

The datagram....

Definition at line 77 of file ECG_UDP_Out_Endpoint.h.

Referenced by operator=().

size_t TAO_ECG_UDP_Out_Endpoint::if_count_ [private]
 

Keep the list of local interfaces, needed for the is_loopback method.

Definition at line 85 of file ECG_UDP_Out_Endpoint.h.

Referenced by is_loopback(), and operator=().

ACE_INET_Addr* TAO_ECG_UDP_Out_Endpoint::ifs_ [private]
 

Definition at line 86 of file ECG_UDP_Out_Endpoint.h.

Referenced by is_loopback(), operator=(), and ~TAO_ECG_UDP_Out_Endpoint().

u_short TAO_ECG_UDP_Out_Endpoint::port_number_ [private]
 

Cache the port-number so we can quickly determine if an event is coming from another endpoint.

Definition at line 81 of file ECG_UDP_Out_Endpoint.h.

Referenced by is_loopback(), and operator=().

ACE_Atomic_Op<TAO_SYNCH_MUTEX,CORBA::ULong> TAO_ECG_UDP_Out_Endpoint::request_id_generator_ [private]
 

The request id....

Definition at line 74 of file ECG_UDP_Out_Endpoint.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:16:25 2006 for TAO_RTEvent by doxygen 1.3.6