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

MEM_Addr.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    MEM_Addr.h
00006  *
00007  *  $Id: MEM_Addr.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Nanbor Wang <nanbor@cs.wustl.edu>
00010  */
00011 //==========================================================================
00012 
00013 
00014 #ifndef ACE_MEM_ADDR_H
00015 #define ACE_MEM_ADDR_H
00016 #include "ace/pre.h"
00017 
00018 #include "ace/ACE_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00025 
00026 #include "ace/INET_Addr.h"
00027 
00028 /**
00029  * @class ACE_MEM_Addr
00030  *
00031  * @brief Defines a C++ wrapper facade for the shared memory transport
00032  * address family format.
00033  */
00034 class ACE_Export ACE_MEM_Addr : public ACE_Addr
00035 {
00036 public:
00037   // = Initialization methods.
00038   /// Default constructor.
00039   ACE_MEM_Addr (void);
00040 
00041   /// Copy constructor.
00042   ACE_MEM_Addr (const ACE_MEM_Addr &);
00043 
00044   /// Creates an <ACE_INET_Addr> from a <port_number> and the remote
00045   /// <host_name>.
00046   ACE_MEM_Addr (u_short port_number);
00047 
00048   /// Creates an <ACE_INET_Addr> from a <port_name>.
00049   ACE_EXPLICIT ACE_MEM_Addr (const ACE_TCHAR port_name[]);
00050 
00051   /// Default dtor.
00052   ~ACE_MEM_Addr (void);
00053 
00054   // = Direct initialization methods.
00055 
00056   /// default initialization routine.
00057   int initialize_local (u_short port);
00058 
00059   /// Check if <sap> designate an enpoint withing the same host.
00060   int same_host (const ACE_INET_Addr& sap);
00061 
00062   // These methods are useful after the object has been constructed.
00063 
00064   /**
00065    * Initializes an <ACE_INET_Addr> from a <port_number> and the
00066    * remote <host_name>.  If <encode> is enabled then <port_number> is
00067    * converted into network byte order, otherwise it is assumed to be
00068    * in network byte order already and are passed straight through.
00069    */
00070   int set (u_short port_number,
00071            int encode = 1);
00072 
00073   /// Uses <getservbyname> to initialize an <ACE_INET_Addr> from a
00074   /// <port_name>, the remote <host_name>, and the <protocol>.
00075   int set (const ACE_TCHAR port_name[]);
00076 
00077   /// Return a pointer to the underlying network address.
00078   virtual void *get_addr (void) const;
00079 
00080   /// Set a pointer to the address.
00081   virtual void set_addr (void *, int len);
00082 
00083   /// Transform the external <ACE_INET_Addr> address into string
00084   /// format.
00085   virtual int addr_to_string (ACE_TCHAR buffer[],
00086                               size_t size,
00087                               int ipaddr_format = 1) const;
00088 
00089   /// Initializes the external <ACE_INET_Addr> from the <address>.
00090   virtual int string_to_addr (const ACE_TCHAR address[]);
00091 
00092   /// Sets the port number.
00093   void set_port_number (u_short,
00094                         int encode = 1);
00095 
00096   /// Return the port number, converting it into host byte order.
00097   u_short get_port_number (void) const;
00098 
00099   /// Return the character representation of the hostname.
00100   int get_host_name (ACE_TCHAR hostname[],
00101                      size_t hostnamelen) const;
00102 
00103   /**
00104    * Return the character representation of the hostname (this version
00105    * is non-reentrant since it returns a pointer to a static data
00106    * area).
00107    */
00108   const char *get_host_name (void) const;
00109 
00110   /// Return the "dotted decimal" external address.
00111   const char *get_host_addr (void) const;
00112 
00113   /// Return the 4-byte external IP address, converting it into host byte
00114   /// order.
00115   ACE_UINT32 get_ip_address (void) const;
00116 
00117   const ACE_INET_Addr &get_remote_addr (void) const;
00118   const ACE_INET_Addr &get_local_addr (void) const;
00119 
00120   /// Compare two addresses for equality.  The addresses are considered
00121   /// equal if they contain the same IP address and port number.
00122   int operator == (const ACE_MEM_Addr &SAP) const;
00123   int operator == (const ACE_INET_Addr &SAP) const;
00124 
00125   /// Compare two addresses for inequality.
00126   int operator != (const ACE_MEM_Addr &SAP) const;
00127   int operator != (const ACE_INET_Addr &SAP) const;
00128 
00129   /// Computes and returns hash value.
00130   virtual u_long hash (void) const;
00131 
00132   /// Dump the state of an object.
00133   void dump (void) const;
00134 
00135   /// Declare the dynamic allocation hooks.
00136   ACE_ALLOC_HOOK_DECLARE;
00137 
00138 private:
00139   /// External INET addr used for identifying host.
00140   ACE_INET_Addr external_;
00141 
00142   /// Internal INET addr for accepting/connecting.
00143   ACE_INET_Addr internal_;
00144 };
00145 
00146 #if defined (__ACE_INLINE__)
00147 #include "ace/MEM_Addr.i"
00148 #endif /* __ACE_INLINE__ */
00149 
00150 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00151 
00152 #include "ace/post.h"
00153 #endif /* ACE_MEM_ADDR_H */

Generated on Mon Jun 16 11:20:16 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002