C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/net/InetAddress.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_INET_ADDRESS_HPP
00008 #define COH_INET_ADDRESS_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 
00013 
00014 COH_OPEN_NAMESPACE2(coherence,net)
00015 
00016 
00017 /**
00018 * InetAddress represents an IP address.
00019 *
00020 * @author mf  2008.03.17
00021 */
00022 class COH_EXPORT InetAddress
00023     : public cloneable_spec<InetAddress>
00024     {
00025     friend class factory<InetAddress>;
00026 
00027     // ----- constructors ---------------------------------------------------
00028 
00029     protected:
00030         /**
00031         * Manually construct an InetAddress from a network byte ordered array.
00032         *
00033         * It is recommended that the #getByName() method be used in place of
00034         * manual InetAddress construction.
00035         *
00036         * @param vsName  the name of the host
00037         * @param vaIP    the array representation of the host's IP address.
00038         */
00039         InetAddress(String::View vsHost, Array<octet_t>::View vaIP);
00040 
00041         /**
00042         * Copy Constructor.
00043         */
00044         InetAddress(const InetAddress&);
00045 
00046 
00047     // ----- InetAddress interface ------------------------------------------
00048 
00049     public:
00050         /**
00051         * Return the InetAddress for the local machine.
00052         *
00053         * @return the local InetAddress.
00054         */
00055         static InetAddress::View getLocalHost();
00056 
00057         /**
00058         * Return the InetAddress for the specified machine name.
00059         *
00060         * @param vHost  the name or IP of the host to resolve
00061         *
00062         * @return the InetAddress for the specified machine name
00063         */
00064         static InetAddress::View getByName(String::View vsHost);
00065 
00066         /**
00067          * Given the name of a host, returns an array of its IP addresses,
00068          * based on the configured name service on the system.
00069          *
00070          * If the host is NULL then an InetAddress representing an address
00071          * of the loopback interface is returned.
00072          *
00073          * @param vsHost  the name of the host, or NULL 
00074          *
00075          * @return an array of all the IP addresses for a given host name
00076          *
00077          * @exception  UnknownHostException  if no IP address for the
00078          *             vsHost could be found.
00079          *
00080          * @since 12.2.1
00081          */
00082         static ObjectArray::Handle getAllByName(String::View vsHost);
00083 
00084         /**
00085          * Returns the loopback address.
00086          *
00087          * @return  the InetAddress loopback instance
00088          *
00089          * @since 12.2.1
00090          */
00091         static InetAddress::View getLoopbackAddress();
00092 
00093         /**
00094         * Return the hostname associated with this address.
00095         *
00096         * @return the hostname associated with this address
00097         */
00098         virtual String::View getHostName() const;
00099 
00100         /**
00101         * Return the address in textual form.
00102         *
00103         * @return the address in textual form
00104         */
00105         virtual String::View getHostAddress() const;
00106 
00107         /**
00108         * Return the raw IP address, in network byte order, with the highest
00109         * order byte stored at index zero.
00110         *
00111         * @return the raw IP address
00112         */
00113         virtual Array<octet_t>::View getAddress() const;
00114 
00115 
00116     // ----- Object interface -----------------------------------------------
00117 
00118     public:
00119         /**
00120         * {@inheritDoc}
00121         */
00122         virtual TypedHandle<const String> toString() const;
00123 
00124         /**
00125         * {@inheritDoc}
00126         */
00127         virtual bool equals(Object::View that) const;
00128 
00129         /**
00130         * {@inheritDoc}
00131         */
00132         virtual size32_t hashCode() const;
00133 
00134 
00135     // ---- data members ----------------------------------------------------
00136 
00137     private:
00138         /**
00139         * The hostname or textual IP for the address.
00140         */
00141         FinalView<String> f_vsHostName;
00142 
00143         /**
00144         * The raw IP address.
00145         */
00146         FinalView<Array<octet_t> > f_vaIP;
00147     };
00148 
00149 COH_CLOSE_NAMESPACE2
00150 
00151 #endif // COH_INET_ADDRESS_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.