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

ACE_INET_Addr Class Reference

Defines a C++ wrapper facade for the Internet domain address family format. More...

#include <INET_Addr.h>

Inheritance diagram for ACE_INET_Addr:

Inheritance graph
[legend]
Collaboration diagram for ACE_INET_Addr:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_INET_Addr (void)
 Default constructor. More...

 ACE_INET_Addr (const ACE_INET_Addr &)
 Copy constructor. More...

 ACE_INET_Addr (const sockaddr_in *, int len)
 Creates an <ACE_INET_Addr> from a sockaddr_in structure. More...

 ACE_INET_Addr (u_short port_number, const char host_name[], int address_family=AF_UNSPEC)
 Creates an <ACE_INET_Addr> from a <port_number> and the remote <host_name>. The port number is assumed to be in host byte order. To set a port already in network byte order, please
See also:
set(). Use address_family to select IPv6 (PF_INET6) vs. IPv4 (PF_INET).
More...


ACE_EXPLICIT ACE_INET_Addr (const char address[])
 Initializes an <ACE_INET_Addr> from the <address>, which can be "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or "128.252.166.57:1234"). More...

 ACE_INET_Addr (u_short port_number, ACE_UINT32 ip_addr=INADDR_ANY)
 Creates an <ACE_INET_Addr> from a <port_number> and an Internet <ip_addr>. More...

 ACE_INET_Addr (const char port_name[], const char host_name[], const char protocol[]="tcp")
 Uses <getservbyname> to create an <ACE_INET_Addr> from a <port_name>, the remote <host_name>, and the <protocol>. More...

 ACE_INET_Addr (const char port_name[], ACE_UINT32 ip_addr, const char protocol[]="tcp")
 Uses <getservbyname> to create an <ACE_INET_Addr> from a <port_name>, an Internet <ip_addr>, and the <protocol>. More...

 ACE_INET_Addr (u_short port_number, const wchar_t host_name[], int address_family=AF_UNSPEC)
ACE_EXPLICIT ACE_INET_Addr (const wchar_t address[])
 ACE_INET_Addr (const wchar_t port_name[], const wchar_t host_name[], const wchar_t protocol[]=ACE_TEXT_WIDE("tcp"))
 ACE_INET_Addr (const wchar_t port_name[], ACE_UINT32 ip_addr, const wchar_t protocol[]=ACE_TEXT_WIDE("tcp"))
 ~ACE_INET_Addr (void)
 Default dtor. More...

int set (const ACE_INET_Addr &)
 Initializes from another <ACE_INET_Addr>. More...

int set (u_short port_number, const char host_name[], int encode=1, int address_family=AF_UNSPEC)
 Initializes an <ACE_INET_Addr> from a <port_number> and the remote <host_name>. More...

int set (u_short port_number, ACE_UINT32 ip_addr=INADDR_ANY, int encode=1)
 Initializes an <ACE_INET_Addr> from a. More...

int set (const char port_name[], const char host_name[], const char protocol[]="tcp")
 Uses <getservbyname> to initialize an <ACE_INET_Addr> from a <port_name>, the remote <host_name>, and the <protocol>. More...

int set (const char port_name[], ACE_UINT32 ip_addr, const char protocol[]="tcp")
 Uses <getservbyname> to initialize an <ACE_INET_Addr> from a <port_name>, an <ip_addr>, and the <protocol>. More...

int set (const char addr[])
 Initializes an <ACE_INET_Addr> from the <addr>, which can be "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or "128.252.166.57:1234"). More...

int set (const sockaddr_in *, int len)
 Creates an <ACE_INET_Addr> from a sockaddr_in structure. More...

int set (u_short port_number, const wchar_t host_name[], int encode=1, int address_family=AF_UNSPEC)
int set (const wchar_t port_name[], const wchar_t host_name[], const wchar_t protocol[]=ACE_TEXT_WIDE("tcp"))
int set (const wchar_t port_name[], ACE_UINT32 ip_addr, const wchar_t protocol[]=ACE_TEXT_WIDE("tcp"))
int set (const wchar_t addr[])
virtual void * get_addr (void) const
 Return a pointer to the underlying network address. More...

int get_addr_size (void) const
virtual void set_addr (void *, int len)
 Set a pointer to the address. More...

virtual int addr_to_string (ACE_TCHAR buffer[], size_t size, int ipaddr_format=1) const
 Transform the current <ACE_INET_Addr> address into string format. More...

virtual int string_to_addr (const char address[])
 Initializes an <ACE_INET_Addr> from the <address>, which can be "ip-addr:port-number" (e.g., "tango.cs.wustl.edu:1234"), "ip-addr:port-name" (e.g., "tango.cs.wustl.edu:telnet"), "ip-number:port-number" (e.g., "128.252.166.57:1234"), or "ip-number:port-name" (e.g., "128.252.166.57:telnet"). More...

void set_port_number (u_short, int encode=1)
 Sets the port number without affecting the host name. More...

int set_address (const char *ip_addr, int len, int encode=1)
 Sets the address without affecting the port number. More...

u_short get_port_number (void) const
 Return the port number, converting it into host byte-order. More...

int get_host_name (char hostname[], size_t hostnamelen) const
 Return the character representation of the name of the host, storing it in the <hostname> (which is assumed to be <hostnamelen> bytes long). More...

int get_host_name (wchar_t hostname[], size_t hostnamelen) const
const char * get_host_name (void) const
 Return the character representation of the hostname (this version is non-reentrant since it returns a pointer to a static data area). More...

const char * get_host_addr (void) const
 Return the "dotted decimal" Internet address. More...

const char * get_host_addr (char *dst, int size) const
ACE_UINT32 get_ip_address (void) const
 Return the 4-byte IP address, converting it into host byte order. More...

int operator< (const ACE_INET_Addr &rhs) const
 Returns true if <this> is less than <rhs>. More...

int operator== (const ACE_INET_Addr &SAP) const
 Compare two addresses for equality. The addresses are considered equal if they contain the same IP address and port number. More...

int operator!= (const ACE_INET_Addr &SAP) const
 Compare two addresses for inequality. More...

virtual u_long hash (void) const
 Computes and returns hash value. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Methods

int get_host_name_i (char hostname[], size_t hostnamelen) const
 Insure that
  • hostname is properly null-terminated.
More...


void * ip_addr_pointer (void) const
size_t ip_addr_size (void) const
int determine_type (void) const

Private Attributes

union {
   sockaddr_in   in4_
inet_addr_
 Underlying representation. This union uses the knowledge that the two structures share the first member, sa_family (as all sockaddr structures do). More...


Detailed Description

Defines a C++ wrapper facade for the Internet domain address family format.


Constructor & Destructor Documentation

ACE_INET_Addr::ACE_INET_Addr void   
 

Default constructor.

ACE_INET_Addr::ACE_INET_Addr const ACE_INET_Addr &    sa
 

Copy constructor.

ACE_INET_Addr::ACE_INET_Addr const sockaddr_in *    addr,
int    len
 

Creates an <ACE_INET_Addr> from a sockaddr_in structure.

ACE_INET_Addr::ACE_INET_Addr u_short    port_number,
const char    host_name[],
int    address_family = AF_UNSPEC
 

Creates an <ACE_INET_Addr> from a <port_number> and the remote <host_name>. The port number is assumed to be in host byte order. To set a port already in network byte order, please

See also:
set(). Use address_family to select IPv6 (PF_INET6) vs. IPv4 (PF_INET).

ACE_INET_Addr::ACE_INET_Addr const char    address[]
 

Initializes an <ACE_INET_Addr> from the <address>, which can be "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or "128.252.166.57:1234").

If there is no ':' in the <address> it is assumed to be a port number, with the IP address being INADDR_ANY.

ACE_INET_Addr::ACE_INET_Addr u_short    port_number,
ACE_UINT32    inet_address = INADDR_ANY
 

Creates an <ACE_INET_Addr> from a <port_number> and an Internet <ip_addr>.

This method assumes that <port_number> and <ip_addr> are in host byte order. If you have addressing information in network byte order,

See also:
set().

ACE_INET_Addr::ACE_INET_Addr const char    port_name[],
const char    host_name[],
const char    protocol[] = "tcp"
 

Uses <getservbyname> to create an <ACE_INET_Addr> from a <port_name>, the remote <host_name>, and the <protocol>.

ACE_INET_Addr::ACE_INET_Addr const char    port_name[],
ACE_UINT32    inet_address,
const char    protocol[] = "tcp"
 

Uses <getservbyname> to create an <ACE_INET_Addr> from a <port_name>, an Internet <ip_addr>, and the <protocol>.

This method assumes that <ip_addr> is in host byte order.

ACE_INET_Addr::ACE_INET_Addr u_short    port_number,
const wchar_t    host_name[],
int    address_family = AF_UNSPEC
 

ACE_INET_Addr::ACE_INET_Addr const wchar_t    address[]
 

ACE_INET_Addr::ACE_INET_Addr const wchar_t    port_name[],
const wchar_t    host_name[],
const wchar_t    protocol[] = ACE_TEXT_WIDE ("tcp")
 

ACE_INET_Addr::ACE_INET_Addr const wchar_t    port_name[],
ACE_UINT32    inet_address,
const wchar_t    protocol[] = ACE_TEXT_WIDE ("tcp")
 

ACE_INLINE ACE_INET_Addr::~ACE_INET_Addr void   
 

Default dtor.


Member Function Documentation

int ACE_INET_Addr::addr_to_string ACE_TCHAR    s[],
size_t    size,
int    ipaddr_format = 1
const [virtual]
 

Transform the current <ACE_INET_Addr> address into string format.

If <ipaddr_format> is non-0 this produces "ip-number:port-number" (e.g., "128.252.166.57:1234"), whereas if <ipaddr_format> is 0 this produces "ip-name:port-number" (e.g., "tango.cs.wustl.edu:1234"). Returns -1 if the <size> of the <buffer> is too small, else 0.

ACE_INLINE int ACE_INET_Addr::determine_type void    const [private]
 

void ACE_INET_Addr::dump void    const
 

Dump the state of an object.

Reimplemented from ACE_Addr.

ACE_INLINE void * ACE_INET_Addr::get_addr void    const [virtual]
 

Return a pointer to the underlying network address.

Reimplemented from ACE_Addr.

ACE_INLINE int ACE_INET_Addr::get_addr_size void    const
 

const char * ACE_INET_Addr::get_host_addr char *    dst,
int    size
const
 

const char * ACE_INET_Addr::get_host_addr void    const
 

Return the "dotted decimal" Internet address.

const char * ACE_INET_Addr::get_host_name void    const
 

Return the character representation of the hostname (this version is non-reentrant since it returns a pointer to a static data area).

int ACE_INET_Addr::get_host_name wchar_t    hostname[],
size_t    len
const
 

int ACE_INET_Addr::get_host_name char    hostname[],
size_t    len
const
 

Return the character representation of the name of the host, storing it in the <hostname> (which is assumed to be <hostnamelen> bytes long).

This version is reentrant. If <hostnamelen> is greater than 0 then <hostname> will be NUL-terminated even if -1 is returned.

int ACE_INET_Addr::get_host_name_i char    hostname[],
size_t    len
const [private]
 

Insure that

  • hostname is properly null-terminated.

ACE_UINT32 ACE_INET_Addr::get_ip_address void    const
 

Return the 4-byte IP address, converting it into host byte order.

ACE_INLINE u_short ACE_INET_Addr::get_port_number void    const
 

Return the port number, converting it into host byte-order.

ACE_INLINE u_long ACE_INET_Addr::hash void    const [virtual]
 

Computes and returns hash value.

Reimplemented from ACE_Addr.

ACE_INLINE void * ACE_INET_Addr::ip_addr_pointer void    const [private]
 

ACE_INLINE size_t ACE_INET_Addr::ip_addr_size void    const [private]
 

int ACE_INET_Addr::operator!= const ACE_INET_Addr &    sap const
 

Compare two addresses for inequality.

ACE_INLINE int ACE_INET_Addr::operator< const ACE_INET_Addr &    rhs const
 

Returns true if <this> is less than <rhs>.

In this context, "less than" is defined in terms of IP address and TCP port number. This operator makes it possible to use <ACE_INET_Addr>s in STL maps.

int ACE_INET_Addr::operator== const ACE_INET_Addr &    sap const
 

Compare two addresses for equality. The addresses are considered equal if they contain the same IP address and port number.

int ACE_INET_Addr::set const wchar_t    addr[]
 

int ACE_INET_Addr::set const wchar_t    port_name[],
ACE_UINT32    ip_addr,
const wchar_t    protocol[] = ACE_TEXT_WIDE ("tcp")
 

int ACE_INET_Addr::set const wchar_t    port_name[],
const wchar_t    host_name[],
const wchar_t    protocol[] = ACE_TEXT_WIDE ("tcp")
 

int ACE_INET_Addr::set u_short    port_number,
const wchar_t    host_name[],
int    encode = 1,
int    address_family = AF_UNSPEC
 

int ACE_INET_Addr::set const sockaddr_in *    addr,
int    len
 

Creates an <ACE_INET_Addr> from a sockaddr_in structure.

int ACE_INET_Addr::set const char    address[]
 

Initializes an <ACE_INET_Addr> from the <addr>, which can be "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or "128.252.166.57:1234").

If there is no ':' in the <address> it is assumed to be a port number, with the IP address being INADDR_ANY.

int ACE_INET_Addr::set const char    port_name[],
ACE_UINT32    inet_address,
const char    protocol[] = "tcp"
 

Uses <getservbyname> to initialize an <ACE_INET_Addr> from a <port_name>, an <ip_addr>, and the <protocol>.

This assumes that <ip_addr> is already in network byte order.

int ACE_INET_Addr::set const char    port_name[],
const char    host_name[],
const char    protocol[] = "tcp"
 

Uses <getservbyname> to initialize an <ACE_INET_Addr> from a <port_name>, the remote <host_name>, and the <protocol>.

int ACE_INET_Addr::set u_short    port_number,
ACE_UINT32    inet_address = INADDR_ANY,
int    encode = 1
 

Initializes an <ACE_INET_Addr> from a.

Parameters:
port_number  and an Internet
ip_addr.  If
encode  is non-zero then the port number and IP address are converted into network byte order, otherwise they are assumed to be in network byte order already and are passed straight through.

int ACE_INET_Addr::set u_short    port_number,
const char    host_name[],
int    encode = 1,
int    address_family = AF_UNSPEC
 

Initializes an <ACE_INET_Addr> from a <port_number> and the remote <host_name>.

If <encode> is non-zero then <port_number> is converted into network byte order, otherwise it is assumed to be in network byte order already and are passed straight through. address_family can be used to select IPv4/IPv6 if the OS has IPv6 capability (ACE_HAS_IPV6 is defined). To specify IPv6, use the value AF_INET6. To specify IPv4, use AF_INET.

int ACE_INET_Addr::set const ACE_INET_Addr &    sa
 

Initializes from another <ACE_INET_Addr>.

void ACE_INET_Addr::set_addr void *    addr,
int    len
[virtual]
 

Set a pointer to the address.

Reimplemented from ACE_Addr.

int ACE_INET_Addr::set_address const char *    ip_addr,
int    len,
int    encode = 1
 

Sets the address without affecting the port number.

If <encode> is enabled then <ip_addr> is converted into network byte order, otherwise it is assumed to be in network byte order already and are passed straight through. The size of the address is specified in the <len> parameter.

void ACE_INET_Addr::set_port_number u_short    port_number,
int    encode = 1
 

Sets the port number without affecting the host name.

If <encode> is enabled then <port_number> is converted into network byte order, otherwise it is assumed to be in network byte order already and are passed straight through.

int ACE_INET_Addr::string_to_addr const char    s[] [virtual]
 

Initializes an <ACE_INET_Addr> from the <address>, which can be "ip-addr:port-number" (e.g., "tango.cs.wustl.edu:1234"), "ip-addr:port-name" (e.g., "tango.cs.wustl.edu:telnet"), "ip-number:port-number" (e.g., "128.252.166.57:1234"), or "ip-number:port-name" (e.g., "128.252.166.57:telnet").

If there is no ':' in the <address> it is assumed to be a port number, with the IP address being INADDR_ANY.


Member Data Documentation

ACE_INET_Addr::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Addr.

sockaddr_in ACE_INET_Addr::in4_ [private]
 

union { ... } ACE_INET_Addr::inet_addr_ [private]
 

Underlying representation. This union uses the knowledge that the two structures share the first member, sa_family (as all sockaddr structures do).


The documentation for this class was generated from the following files:
Generated on Thu May 23 00:18:07 2002 for ACE by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001