InetAddress.h

Go to the documentation of this file.
00001 #ifndef JAVA_NET_INETADDRESS_H
00002 #define JAVA_NET_INETADDRESS_H 1
00003 
00004 #ifndef JAVA_LANG_OBJECT_H
00005 #include <java_lang/Object.h>
00006 #endif /* JAVA_LANG_OBJECT_H */
00007 #ifndef JAVA_NET_SPEC
00008 #include <java_net/Spec.h>
00009 #endif /* JAVA_NET_SPEC */
00010 
00011 namespace java {
00012   namespace net {
00013 
00152     class JAVA_NET_SPEC InetAddress : virtual public Object {
00153 
00154     public:
00155 
00156       enum INET_PROTOCOL { 
00157 
00162         IPv4=1, 
00163 
00168         IPv6
00169 
00170       };
00171 
00172       /* Specify address family preference */
00173       static jboolean preferIPv6Address;
00174       static const jboolean isIPv6Available;
00175 
00182       InetAddress();
00183   
00191       virtual jboolean isMulticastAddress() const;
00192 
00199       virtual jboolean isAnyLocalAddress() const;
00200 
00208       virtual jboolean isLoopbackAddress() const;
00209 
00217       virtual jboolean isLinkLocalAddress() const;
00218 
00226       virtual jboolean isSiteLocalAddress() const;
00227 
00236       virtual jboolean isMCGlobal() const;
00237 
00246       virtual jboolean isMCNodeLocal() const;
00247 
00256       virtual jboolean isMCLinkLocal() const;
00257 
00266       virtual jboolean isMCSiteLocal() const;
00267 
00277       virtual jboolean isMCOrgLocal() const;
00278 
00304       virtual String getHostName();
00305 
00327       virtual String getCanonicalHostName();
00328 
00336       virtual Array<jbyte> getAddress() const;
00337 
00344       virtual String getHostAddress() const;
00345 
00351       virtual jint getFamily() const;
00352 
00358       virtual jint hashCode() const;
00359 
00376       virtual jboolean equals(const Object& obj) const;
00377 
00388       virtual String toString() const;
00389 
00415       static Ref<InetAddress> getByAddress(const String& host, const Array<jbyte>& addr);
00416 
00437       static Ref<InetAddress> getByName(const String& host);
00438 
00469       static Array<Ref<InetAddress> > getAllByName(const String& host);
00470 
00487       static Ref<InetAddress> getByAddress(const Array<jbyte>& addr);
00488 
00506       static Ref<InetAddress> getLocalHost();
00507 
00508       /*
00509        * Returns the InetAddress representing anyLocalAddress
00510        * (typically 0.0.0.0 or ::0)
00511        */
00512       static Ref<InetAddress> anyLocalAddress();
00513 
00514     protected:
00515 
00516       InetAddress(const String& hostName, const Array<jbyte>& addr, jint family);
00517 
00518       String hostName;
00519 
00524       Array<jbyte> address;
00525 
00530       jint family;
00531 
00532     private:
00533 
00534       /* Used to store the best available hostname */
00535       String canonicalHostName;
00536 
00548       static String getHostFromNameService(const InetAddress& addr);
00549 
00550       REGISTER_MEMBERS;
00551 
00552     };
00553 
00554   } // namespace net
00555 } // namespace java
00556 
00557 #endif /* JAVA_NET_INETADDRESS_H */

Generated on Fri May 16 11:54:43 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3