Use override/default for RTPortableServer
[ACE_TAO.git] / ACE / ace / Multihomed_INET_Addr.h
blob58879c62632918a02b3e6801f9edb3896492ca64
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Multihomed_INET_Addr.h
7 * @author Edward R. Mulholland <emulholl@atl.lmco.com>
8 */
9 //=============================================================================
11 #ifndef ACE_MULTIHOMED_INET_ADDR_H
12 #define ACE_MULTIHOMED_INET_ADDR_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/ACE_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/INET_Addr.h"
23 #include "ace/Containers_T.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 /**
28 * @class ACE_Multihomed_INET_Addr
30 * @brief Extends ACE_INET_Addr with support for multi-homed
31 * addresses.
33 class ACE_Export ACE_Multihomed_INET_Addr : public ACE_INET_Addr
35 public:
36 /// Default constructor.
37 ACE_Multihomed_INET_Addr ();
39 /**
40 * Initializes an ACE_Multihomed_INET_Addr from the @a address,
41 * which can be "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234"
42 * or "128.252.166.57:1234"). If there is no ':' in the @a address it
43 * is assumed to be a port number, with the IP address being
44 * INADDR_ANY.
46 explicit ACE_Multihomed_INET_Addr (const char address[]);
48 /**
49 * Constructs an ACE_Multihomed_INET_Addr from a @a port_number, a
50 * @a primary_host_name, and an array of @a secondary_host_names.
51 * @a size is taken to be the length of the array. If @a encode is
52 * non-zero, then @a port_number is converted into network byte
53 * order; otherwise it is assumed to be in network byte order
54 * already and is passed straight through. @a address_family can be
55 * used to select IPv4/IPv6 if the OS has IPv6 capability
56 * (ACE_HAS_IPV6 is defined). To specify IPv6, use the value
57 * AF_INET6. To specify IPv4, use AF_INET.
59 ACE_Multihomed_INET_Addr(u_short port_number,
60 const char primary_host_name[],
61 int encode = 1,
62 int address_family = AF_UNSPEC,
63 const char *(secondary_host_names[]) = 0,
64 size_t size = 0);
66 /**
67 * Constructs an ACE_Multihomed_INET_Addr from a @a port_number,
68 * a @a primary_ip_addr, and an array of @a secondary_ip_addrs. @a
69 * size is taken to be the length of the array. If @a encode is
70 * non-zero, then the port number and the IP addresses are converted
71 * into network byte order; otherwise they are assumed to be in
72 * network byte order already and are passed straight through.
74 ACE_Multihomed_INET_Addr(u_short port_number,
75 ACE_UINT32 primary_ip_addr = INADDR_ANY,
76 int encode = 1,
77 const ACE_UINT32 *secondary_ip_addrs = 0,
78 size_t size = 0);
80 #if defined (ACE_HAS_WCHAR)
81 /**
82 * WCHAR versions of the methods that take char's as arguments.
84 ACE_Multihomed_INET_Addr(u_short port_number,
85 const wchar_t primary_host_name[],
86 int encode = 1,
87 int address_family = AF_UNSPEC,
88 const wchar_t *(secondary_host_names[]) = 0,
89 size_t size = 0);
91 int set (u_short port_number,
92 const wchar_t primary_host_name[],
93 int encode = 1,
94 int address_family = AF_UNSPEC,
95 const wchar_t *(secondary_host_names[]) = 0,
96 size_t size = 0);
98 #endif /* ACE_HAS_WCHAR */
100 /// Use compiler-generated copy constructor.
102 /// Use compiler-generated assignment operator.
104 /// Default destructor.
105 ~ACE_Multihomed_INET_Addr ();
107 // = Direct initialization methods.
109 // These methods are useful after the object has been constructed.
112 * Initializes an ACE_Multihomed_INET_Addr from a @a port_number, a
113 * @a primary_host_name, and an array of @a secondary_host_names.
114 * @a size is taken to be the length of the array. If @a encode is
115 * non-zero, then @a port_number is converted into network byte
116 * order; otherwise it is assumed to be in network byte order
117 * already and is passed straight through. @a address_family can be
118 * used to select IPv4/IPv6 if the OS has IPv6 capability
119 * (ACE_HAS_IPV6 is defined). To specify IPv6, use the value
120 * AF_INET6. To specify IPv4, use AF_INET.
122 int set (u_short port_number,
123 const char primary_host_name[],
124 int encode = 1,
125 int address_family = AF_UNSPEC,
126 const char *(secondary_host_names[]) = 0,
127 size_t size = 0);
130 * Initializes an ACE_Multihomed_INET_Addr from a @a port_number,
131 * a @a primary_ip_addr, and an array of @a secondary_ip_addrs. @a
132 * size is taken to be the length of the array. If @a encode is
133 * non-zero, then the port number and the IP addresses are converted
134 * into network byte order; otherwise they are assumed to be in
135 * network byte order already and are passed straight through.
137 int set (u_short port_number,
138 ACE_UINT32 primary_ip_addr = INADDR_ANY,
139 int encode = 1,
140 const ACE_UINT32 *secondary_ip_addrs = 0,
141 size_t size = 0);
144 * Sets the port number without affecting the host name. The port
145 * numbers of the primary address, and of any and all secondary
146 * addresses, are affected. If @a encode is enabled, then
147 * @a port_number is converted into network byte order, otherwise it
148 * is assumed to be in network byte order already and is passed
149 * straight through.
151 void set_port_number (u_short port_number,
152 int encode = 1);
154 // = Accessor methods.
157 * Returns the number of secondary addresses.
159 size_t get_num_secondary_addresses () const;
162 * Initialize user-supplied array @a secondary_addrs with the current
163 * secondary addresses. @a size is taken as the size of this array.
165 int get_secondary_addresses(ACE_INET_Addr *secondary_addrs,
166 size_t size) const;
169 * Initialize user-supplied array @a addrs with the the current
170 * primary and secondary addresses. @a size is taken as the size of
171 * this array.
173 void get_addresses(sockaddr_in *addrs, size_t size) const;
175 #if defined (ACE_HAS_IPV6)
177 /// IPV6 version of the above.
178 void get_addresses(sockaddr_in6 *addrs, size_t size) const;
179 #endif /* ACE_HAS_IPV6 */
181 /// Declare the dynamic allocation hooks.
182 ACE_ALLOC_HOOK_DECLARE;
184 private:
185 ACE_Array<ACE_INET_Addr> secondaries_;
188 ACE_END_VERSIONED_NAMESPACE_DECL
190 #if defined (__ACE_INLINE__)
191 # include "ace/Multihomed_INET_Addr.inl"
192 #endif /* __ACE_INLINE__ */
194 #include /**/ "ace/post.h"
196 #endif /* ACE_MULTIHOMED_INET_ADDR_H */