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

TAO_IIOP_Endpoint Class Reference

TAO_IIOP_Endpoint. More...

#include <IIOP_Endpoint.h>

Inheritance diagram for TAO_IIOP_Endpoint:

Inheritance graph
[legend]
Collaboration diagram for TAO_IIOP_Endpoint:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_IIOP_Endpoint (void)
 Default constructor. More...

 TAO_IIOP_Endpoint (const char *host, CORBA::UShort port, const ACE_INET_Addr &addr)
 Constructor. This is the most efficient constructor since it does not require any address resolution processing. More...

 TAO_IIOP_Endpoint (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses)
 Constructor. More...

 TAO_IIOP_Endpoint (const char *host, CORBA::UShort port, CORBA::Short priority)
 Constructor. This constructor is used when decoding endpoints. More...

 ~TAO_IIOP_Endpoint (void)
 Destructor. More...

virtual TAO_Endpointnext (void)
 Endpoints can be stringed in a list. Return the next endpoint in the list, if any. More...

virtual int addr_to_string (char *buffer, size_t length)
virtual void reset_hint (void)
 This method is used when a connection has been reset, requiring the hint to be cleaned up and reset to NULL. More...

virtual TAO_Endpointduplicate (void)
 Makes a copy of <this>. More...

CORBA::Boolean is_equivalent (const TAO_Endpoint *other_endpoint)
 Return true if this endpoint is equivalent to <other_endpoint>. Two endpoints are equivalent iff their port and host are the same. More...

CORBA::ULong hash (void)
 Return a hash value for this object. More...

const ACE_INET_Addrobject_addr (void) const
 Return a reference to the <object_addr>. More...

const char * host (void) const
 Return a pointer to the host string. This object maintains ownership of this string. More...

const char * host (const char *h)
 Copy the string <h> into <host_> and return the resulting pointer. This object maintains ownership of this string. More...

CORBA::UShort port (void) const
 Return the port number. More...

CORBA::UShort port (CORBA::UShort p)
 Set the port number. More...


Private Methods

int set (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses)
 Helper method for setting INET_Addr. More...


Private Attributes

CORBA::String_var host_
 String representing the host name. More...

CORBA::UShort port_
 TCP port number. More...

ACE_INET_Addr object_addr_
 Cached instance of <ACE_INET_Addr> for use in making invocations, etc. More...

int object_addr_set_
 Flag to indicate if the address has been resolved and set. More...

TAO_IIOP_Endpoint * next_
 IIOP Endpoints can be stringed into a list. Return the next endpoint in the list, if any. More...


Friends

class TAO_IIOP_Profile
class TAO_SSLIOP_Profile

Detailed Description

TAO_IIOP_Endpoint.

IIOP-specific implementation of PP Framework Endpoint interface.

Definition at line 42 of file IIOP_Endpoint.h.


Constructor & Destructor Documentation

TAO_IIOP_Endpoint::TAO_IIOP_Endpoint void   
 

Default constructor.

Definition at line 43 of file IIOP_Endpoint.cpp.

References IOP::TAG_INTERNET_IOP.

00044   : TAO_Endpoint (IOP::TAG_INTERNET_IOP),
00045     host_ (),
00046     port_ (683),  // default port (IANA assigned)
00047     object_addr_ (),
00048     object_addr_set_ (0),
00049     next_ (0)
00050 {
00051 }

TAO_IIOP_Endpoint::TAO_IIOP_Endpoint const char *    host,
CORBA::UShort    port,
const ACE_INET_Addr   addr
 

Constructor. This is the most efficient constructor since it does not require any address resolution processing.

Definition at line 29 of file IIOP_Endpoint.cpp.

References host, host_, and IOP::TAG_INTERNET_IOP.

00032   : TAO_Endpoint (IOP::TAG_INTERNET_IOP),
00033     host_ (),
00034     port_ (port),
00035     object_addr_ (addr),
00036     object_addr_set_ (0),
00037     next_ (0)
00038 {
00039   if (host != 0)
00040     this->host_ = host;
00041 }

TAO_IIOP_Endpoint::TAO_IIOP_Endpoint const ACE_INET_Addr   addr,
int    use_dotted_decimal_addresses
 

Constructor.

Definition at line 17 of file IIOP_Endpoint.cpp.

References set, and IOP::TAG_INTERNET_IOP.

00019   : TAO_Endpoint (IOP::TAG_INTERNET_IOP),
00020     host_ (),
00021     port_ (683),  // default port (IANA assigned)
00022     object_addr_ (addr),
00023     object_addr_set_ (0),
00024     next_ (0)
00025 {
00026   this->set (addr, use_dotted_decimal_addresses);
00027 }

TAO_IIOP_Endpoint::TAO_IIOP_Endpoint const char *    host,
CORBA::UShort    port,
CORBA::Short    priority
 

Constructor. This constructor is used when decoding endpoints.

Definition at line 53 of file IIOP_Endpoint.cpp.

References host, host_, TAO_Endpoint::priority, and IOP::TAG_INTERNET_IOP.

00056   : TAO_Endpoint (IOP::TAG_INTERNET_IOP),
00057     host_ (),
00058     port_ (port),
00059     object_addr_ (),
00060     object_addr_set_ (0),
00061     next_ (0)
00062 {
00063   if (host != 0)
00064     this->host_ = host;
00065 
00066   this->priority (priority);
00067 }

TAO_IIOP_Endpoint::~TAO_IIOP_Endpoint void   
 

Destructor.

Definition at line 69 of file IIOP_Endpoint.cpp.

00070 {
00071 }


Member Function Documentation

int TAO_IIOP_Endpoint::addr_to_string char *    buffer,
size_t    length
[virtual]
 

Return a string representation for the address. Returns -1 if buffer is too small. The purpose of this method is to provide a general interface to the underlying address object's addr_to_string method. This allows the protocol implementor to select the appropriate string format.

Implements TAO_Endpoint.

Definition at line 105 of file IIOP_Endpoint.cpp.

References port_, ACE_OS::sprintf, and ACE_OS_String::strlen.

00106 {
00107   size_t actual_len =
00108     ACE_OS::strlen (this->host_.in ()) // chars in host name
00109     + sizeof (':')                     // delimiter
00110     + ACE_OS::strlen ("65536")         // max port
00111     + sizeof ('\0');
00112 
00113   if (length < actual_len)
00114     return -1;
00115 
00116   ACE_OS::sprintf (buffer, "%s:%d",
00117                    this->host_.in (), this->port_);
00118 
00119   return 0;
00120 }

TAO_Endpoint * TAO_IIOP_Endpoint::duplicate void    [virtual]
 

Makes a copy of <this>.

Implements TAO_Endpoint.

Definition at line 145 of file IIOP_Endpoint.cpp.

References ACE_NEW_RETURN, object_addr_, and port_.

00146 {
00147   // @@ Bala, we probably need to make sure that the duplicate has the
00148   // same priority as the original.  Although it does not matter in
00149   // the context this method is currently used, if somebody ends up
00150   // using this method for some other purpose later, this will be a
00151   // seed for bugs.
00152 
00153   TAO_IIOP_Endpoint *endpoint = 0;
00154 
00155   ACE_NEW_RETURN (endpoint,
00156                   TAO_IIOP_Endpoint (this->host_.in (),
00157                                      this->port_,
00158                                      this->object_addr_),
00159                   0);
00160 
00161   return endpoint;
00162 }

CORBA::ULong TAO_IIOP_Endpoint::hash void    [virtual]
 

Return a hash value for this object.

Implements TAO_Endpoint.

Definition at line 180 of file IIOP_Endpoint.cpp.

References ACE_INET_Addr::get_ip_address, object_addr, and port.

Referenced by TAO_IIOP_Profile::hash.

00181 {
00182   // We could call ACE_INET_Addr::hash() since it does much the same
00183   // thing except that it converts the port from network byte order to
00184   // host byte order.  As such, this implementation is actually less
00185   // costly.
00186   return this->object_addr ().get_ip_address () + this->port ();
00187 }

const char * TAO_IIOP_Endpoint::host const char *    h
 

Copy the string <h> into <host_> and return the resulting pointer. This object maintains ownership of this string.

Definition at line 123 of file IIOP_Endpoint.cpp.

References host_.

00124 {
00125   this->host_ = h;
00126 
00127   return this->host_.in ();
00128 }

ACE_INLINE const char * TAO_IIOP_Endpoint::host void    const
 

Return a pointer to the host string. This object maintains ownership of this string.

Definition at line 52 of file IIOP_Endpoint.i.

References host_.

Referenced by TAO_IIOP_Profile::encode_endpoints, TAO_IIOP_Profile::encode_endpoints_for_rt, TAO_IIOP_Acceptor::is_collocated, is_equivalent, TAO_IIOP_Connector::make_connection, and TAO_IIOP_Endpoint.

00053 {
00054   return this->host_.in ();
00055 }

CORBA::Boolean TAO_IIOP_Endpoint::is_equivalent const TAO_Endpoint   other_endpoint [virtual]
 

Return true if this endpoint is equivalent to <other_endpoint>. Two endpoints are equivalent iff their port and host are the same.

Implements TAO_Endpoint.

Definition at line 165 of file IIOP_Endpoint.cpp.

References host, port_, and ACE_OS_String::strcmp.

Referenced by TAO_IIOP_Profile::is_equivalent.

00166 {
00167   TAO_Endpoint *endpt =
00168     ACE_const_cast (TAO_Endpoint *, other_endpoint);
00169 
00170   TAO_IIOP_Endpoint *endpoint =
00171     ACE_dynamic_cast (TAO_IIOP_Endpoint *, endpt);
00172   if (endpoint == 0)
00173     return 0;
00174 
00175   return (this->port_ == endpoint->port_
00176           && (ACE_OS::strcmp(this->host(), endpoint->host()) == 0));
00177 }

TAO_Endpoint * TAO_IIOP_Endpoint::next void    [virtual]
 

Endpoints can be stringed in a list. Return the next endpoint in the list, if any.

Implements TAO_Endpoint.

Definition at line 139 of file IIOP_Endpoint.cpp.

References next_.

00140 {
00141   return this->next_;
00142 }

ACE_INLINE const ACE_INET_Addr & TAO_IIOP_Endpoint::object_addr void    const
 

Return a reference to the <object_addr>.

Definition at line 5 of file IIOP_Endpoint.i.

References ACE_GUARD_RETURN, TAO_Endpoint::addr_lookup_lock_, object_addr_, object_addr_set_, ACE_INET_Addr::set, and TAO_SYNCH_MUTEX.

Referenced by hash, TAO_IIOP_Connector::make_connection, and TAO_IIOP_Connector::set_validate_endpoint.

00006 {
00007   // The object_addr_ is initialized here, rather than at IOR decode
00008   // time for several reasons:
00009   //   1. A request on the object may never be invoked.
00010   //   2. The DNS setup may have changed dynamically.
00011   //   ...etc..
00012 
00013   // Double checked locking optimization.
00014   if (!this->object_addr_set_)
00015     {
00016       // We need to modify the object_addr_ in this method.  Do so
00017       // using a non-const copy of the <this> pointer.
00018       TAO_IIOP_Endpoint *endpoint =
00019         ACE_const_cast (TAO_IIOP_Endpoint *, this);
00020 
00021       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00022                         guard,
00023                         endpoint->addr_lookup_lock_,
00024                         this->object_addr_ );
00025 
00026       if (!this->object_addr_set_)
00027         {
00028           if (endpoint->object_addr_.set (this->port_,
00029                                           this->host_.in ()) == -1)
00030             {
00031               // If this call fails, it most likely due a hostname
00032               // lookup failure caused by a DNS misconfiguration.  If
00033               // a request is made to the object at the given host and
00034               // port, then a CORBA::TRANSIENT() exception should be
00035               // thrown.
00036 
00037               // Invalidate the ACE_INET_Addr.  This is used as a flag
00038               // to denote that ACE_INET_Addr initialization failed.
00039               endpoint->object_addr_.set_type (-1);
00040             }
00041           else
00042             {
00043               endpoint->object_addr_set_ = 1;
00044             }
00045         }
00046     }
00047 
00048   return this->object_addr_;
00049 }

ACE_INLINE CORBA::UShort TAO_IIOP_Endpoint::port CORBA::UShort    p
 

Set the port number.

Definition at line 64 of file IIOP_Endpoint.i.

References port_.

00065 {
00066   return this->port_ = p;
00067 }

ACE_INLINE CORBA::UShort TAO_IIOP_Endpoint::port void    const
 

Return the port number.

Definition at line 58 of file IIOP_Endpoint.i.

References port_.

Referenced by TAO_IIOP_Profile::encode_endpoints, TAO_IIOP_Profile::encode_endpoints_for_rt, hash, TAO_IIOP_Acceptor::is_collocated, TAO_IIOP_Connector::make_connection, and TAO_IIOP_Profile::to_string.

00059 {
00060   return this->port_;
00061 }

void TAO_IIOP_Endpoint::reset_hint void    [virtual]
 

This method is used when a connection has been reset, requiring the hint to be cleaned up and reset to NULL.

Implements TAO_Endpoint.

Definition at line 131 of file IIOP_Endpoint.cpp.

00132 {
00133   // Commented out for the time being....
00134   /*  if (this->hint_)
00135       this->hint_->cleanup_hint ((void **) &this->hint_); */
00136 }

int TAO_IIOP_Endpoint::set const ACE_INET_Addr   addr,
int    use_dotted_decimal_addresses
[private]
 

Helper method for setting INET_Addr.

Definition at line 74 of file IIOP_Endpoint.cpp.

References ACE_DEBUG, ACE_TEXT, ACE_INET_Addr::get_host_addr, ACE_INET_Addr::get_host_name, ACE_INET_Addr::get_port_number, host_, LM_DEBUG, MAXHOSTNAMELEN, port_, and CORBA::string_dup.

Referenced by TAO_IIOP_Endpoint.

00076 {
00077   char tmp_host[MAXHOSTNAMELEN + 1];
00078 
00079   if (use_dotted_decimal_addresses
00080       || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0)
00081     {
00082       const char *tmp = addr.get_host_addr ();
00083       if (tmp == 0)
00084         {
00085           if (TAO_debug_level > 0)
00086             ACE_DEBUG ((LM_DEBUG,
00087                         ACE_TEXT ("\n\nTAO (%P|%t) ")
00088                         ACE_TEXT ("IIOP_Endpoint::set ")
00089                         ACE_TEXT ("- %p\n\n"),
00090                         ACE_TEXT ("cannot determine hostname")));
00091           return -1;
00092         }
00093       else
00094         this->host_ = tmp;
00095     }
00096   else
00097     this->host_ = CORBA::string_dup (tmp_host);
00098 
00099   this->port_ = addr.get_port_number();
00100 
00101   return 0;
00102 }


Friends And Related Function Documentation

friend class TAO_IIOP_Profile [friend]
 

Definition at line 46 of file IIOP_Endpoint.h.

friend class TAO_SSLIOP_Profile [friend]
 

Definition at line 47 of file IIOP_Endpoint.h.


Member Data Documentation

CORBA::String_var TAO_IIOP_Endpoint::host_ [private]
 

String representing the host name.

Definition at line 120 of file IIOP_Endpoint.h.

Referenced by host, set, and TAO_IIOP_Endpoint.

TAO_IIOP_Endpoint* TAO_IIOP_Endpoint::next_ [private]
 

IIOP Endpoints can be stringed into a list. Return the next endpoint in the list, if any.

Definition at line 134 of file IIOP_Endpoint.h.

Referenced by TAO_IIOP_Profile::add_endpoint, TAO_IIOP_Profile::encode_endpoints, TAO_IIOP_Profile::encode_endpoints_for_rt, TAO_IIOP_Profile::hash, TAO_IIOP_Profile::is_equivalent, and next.

ACE_INET_Addr TAO_IIOP_Endpoint::object_addr_ [private]
 

Cached instance of <ACE_INET_Addr> for use in making invocations, etc.

Definition at line 127 of file IIOP_Endpoint.h.

Referenced by TAO_IIOP_Profile::decode, duplicate, and object_addr.

int TAO_IIOP_Endpoint::object_addr_set_ [private]
 

Flag to indicate if the address has been resolved and set.

Definition at line 130 of file IIOP_Endpoint.h.

Referenced by object_addr.

CORBA::UShort TAO_IIOP_Endpoint::port_ [private]
 

TCP port number.

Definition at line 123 of file IIOP_Endpoint.h.

Referenced by addr_to_string, duplicate, is_equivalent, port, and set.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:20:06 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002