Java Doc for InetAddress.java in  » Apache-Harmony-Java-SE » java-package » java » net » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.net 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.net.InetAddress

All known Subclasses:   java.net.Inet6Address,  java.net.Inet4Address,
InetAddress
public class InetAddress extends Object implements Serializable(Code)
The Internet Protocol (IP) address class. This class encapsulates an IP address and provides name and reverse name resolution functions. The address is stored in network order, but as a signed (rather than unsigned) integer.

Inner Class :class CacheElement
Inner Class :static class Cache

Field Summary
static  InetAddressANY
    
final static  InetAddressLOOPBACK
    
final static  byte[]any_bytes
    
 intfamily
    
 StringhostName
    
 byte[]ipaddress
    
final static  byte[]localhost_bytes
    

Constructor Summary
 InetAddress()
     Constructs an InetAddress.
 InetAddress(byte[] address)
     Constructs an InetAddress, representing the address and hostName.
 InetAddress(byte[] address, String hostName)
     Constructs an InetAddress, representing the address and hostName.

Method Summary
static  intbytesToInt(byte bytes, int start)
     Takes the byte array and creates an integer out of four bytes starting at start as the high-order byte.
 CacheElementcacheElement()
    
static  InetAddresscreateHostNameFromIPAddress(String ipAddressString)
     Creates an InetAddress based on an ipAddressString.
public  booleanequals(Object obj)
     Compares this InetAddress against the specified object.
public  byte[]getAddress()
     Returns the IP address of this InetAddress as an array.
native static  InetAddress[]getAliasesByNameImpl(String name)
     Query the IP stack for aliases for the host.
public static  InetAddress[]getAllByName(String host)
     Answer the IP addresses of a named host.
public static  InetAddressgetByAddress(byte[] ipAddress)
     Answers the InetAddress corresponding to the array of bytes.
static  InetAddressgetByAddress(byte[] ipAddress, int scope_id)
     Answers the InetAddress corresponding to the array of bytes.
public static  InetAddressgetByAddress(String hostName, byte[] ipAddress)
     Answers the InetAddress corresponding to the array of bytes, and the given hostname.
static  InetAddressgetByAddressInternal(String hostName, byte[] ipAddress, int scope_id)
     Answers the InetAddress corresponding to the array of bytes, and the given hostname.
public static  InetAddressgetByName(String host)
     Answers the address of a host, given a host string name.
public  StringgetCanonicalHostName()
    
public  StringgetHostAddress()
     Answer the dotted string IP address representing this address.
native static  InetAddressgetHostByAddrImpl(byte[] addr)
     Query the IP stack for the host address.
native static  InetAddressgetHostByNameImpl(String name, boolean preferIPv6Address)
     Query the IP stack for the host address.
public  StringgetHostName()
     Answer the host name.
native static  StringgetHostNameImpl()
     Query the IP stack for the host machine name.
static  StringgetHostNameInternal(String host)
    
public static  InetAddressgetLocalHost()
     Answer the local host, if allowed by the security policy.
public  inthashCode()
     Answer a hashcode for this IP address.
static  intinetAddr(String host)
    
native static  intinetAddrImpl(String host)
     Convert a string containing an Ipv4 Internet Protocol dotted address into a binary address.
native static  StringinetNtoaImpl(int hipAddr)
     Convert a binary address into a string containing an Ipv4 Internet Protocol dotted address.
static  voidintToBytes(int value, byte bytes, int start)
     Takes the integer and chops it into 4 bytes, putting it into the byte array starting with the high order byte at the index start.
public  booleanisAnyLocalAddress()
     Method isAnyLocalAddress.
public  booleanisLinkLocalAddress()
     Answers true if the address is a link local address.
public  booleanisLoopbackAddress()
     Answer true if the address is a loop back address.
public  booleanisMCGlobal()
     Answers true if the address is a global multicast address.
public  booleanisMCLinkLocal()
     Answers true if the address is a link local multicast address.
public  booleanisMCNodeLocal()
     Answers true if the address is a node local multicast address.
public  booleanisMCOrgLocal()
     Answers true if the address is a organization local multicast address.
public  booleanisMCSiteLocal()
     Answers true if the address is a site local multicast address.
public  booleanisMulticastAddress()
     Answer true if the InetAddress is an IP multicast address.
public  booleanisReachable(int timeout)
     Tries to see if the InetAddress is reachable.
public  booleanisReachable(NetworkInterface netif, int ttl, int timeout)
     Tries to see if the InetAddress is reachable.
public  booleanisSiteLocalAddress()
     Answers true if the address is a site local address.
static synchronized  InetAddresslookupHostByName(String host)
    
static  booleanpreferIPv6Addresses()
    
public  StringtoString()
     Answers a string containing a concise, human-readable description of the address.

Field Detail
ANY
static InetAddress ANY(Code)



LOOPBACK
final static InetAddress LOOPBACK(Code)



any_bytes
final static byte[] any_bytes(Code)



family
int family(Code)



hostName
String hostName(Code)



ipaddress
byte[] ipaddress(Code)



localhost_bytes
final static byte[] localhost_bytes(Code)




Constructor Detail
InetAddress
InetAddress()(Code)
Constructs an InetAddress.



InetAddress
InetAddress(byte[] address)(Code)
Constructs an InetAddress, representing the address and hostName.
Parameters:
  address - network address



InetAddress
InetAddress(byte[] address, String hostName)(Code)
Constructs an InetAddress, representing the address and hostName.
Parameters:
  address - network address




Method Detail
bytesToInt
static int bytesToInt(byte bytes, int start)(Code)
Takes the byte array and creates an integer out of four bytes starting at start as the high-order byte. This method makes no checks on the validity of the parameters.



cacheElement
CacheElement cacheElement()(Code)



createHostNameFromIPAddress
static InetAddress createHostNameFromIPAddress(String ipAddressString) throws UnknownHostException(Code)
Creates an InetAddress based on an ipAddressString. No error handling is performed here.



equals
public boolean equals(Object obj)(Code)
Compares this InetAddress against the specified object.
Parameters:
  obj - the object to be tested for equality boolean true, if the objects are equal



getAddress
public byte[] getAddress()(Code)
Returns the IP address of this InetAddress as an array. The elements are in network order (the highest order address byte is in the zero-th element). byte[] the address as a byte array



getAliasesByNameImpl
native static InetAddress[] getAliasesByNameImpl(String name) throws UnknownHostException(Code)
Query the IP stack for aliases for the host. The host is in string name form.
Parameters:
  name - the host name to lookup
throws:
  UnknownHostException - if an error occurs during lookup



getAllByName
public static InetAddress[] getAllByName(String host) throws UnknownHostException(Code)
Answer the IP addresses of a named host. The host name may either be a machine name or a dotted string IP address. If the host name is empty or null, an UnknownHostException is thrown. If the host name is a dotted IP string, an array with the corresponding single InetAddress is returned.
Parameters:
  host - the hostName to be resolved to an address InetAddress[] an array of addresses for the host
throws:
  UnknownHostException - if the address lookup fails



getByAddress
public static InetAddress getByAddress(byte[] ipAddress) throws UnknownHostException(Code)
Answers the InetAddress corresponding to the array of bytes. In the case of an IPv4 address there must be exactly 4 bytes and for IPv6 exactly 16 bytes. If not, an UnknownHostException is thrown. The IP address is not validated by a name service. The high order byte is ipAddress[0].
Parameters:
  ipAddress - either a 4 (IPv4) or 16 (IPv6) byte array the InetAddress
throws:
  UnknownHostException -



getByAddress
static InetAddress getByAddress(byte[] ipAddress, int scope_id) throws UnknownHostException(Code)
Answers the InetAddress corresponding to the array of bytes. In the case of an IPv4 address there must be exactly 4 bytes and for IPv6 exactly 16 bytes. If not, an UnknownHostException is thrown. The IP address is not validated by a name service. The high order byte is ipAddress[0].
Parameters:
  ipAddress - either a 4 (IPv4) or 16 (IPv6) byte array
Parameters:
  scope_id - the scope id for an IPV6 scoped address. If not a scopedaddress just pass in 0 the InetAddress
throws:
  UnknownHostException -



getByAddress
public static InetAddress getByAddress(String hostName, byte[] ipAddress) throws UnknownHostException(Code)
Answers the InetAddress corresponding to the array of bytes, and the given hostname. In the case of an IPv4 address there must be exactly 4 bytes and for IPv6 exactly 16 bytes. If not, an UnknownHostException is thrown. The host name and IP address are not validated. The hostname either be a machine alias or a valid IPv6 or IPv4 address format. The high order byte is ipAddress[0].
Parameters:
  hostName - string representation of hostname or ip address
Parameters:
  ipAddress - either a 4 (IPv4) or 16 (IPv6) byte array the InetAddress
throws:
  UnknownHostException -



getByAddressInternal
static InetAddress getByAddressInternal(String hostName, byte[] ipAddress, int scope_id) throws UnknownHostException(Code)
Answers the InetAddress corresponding to the array of bytes, and the given hostname. In the case of an IPv4 address there must be exactly 4 bytes and for IPv6 exactly 16 bytes. If not, an UnknownHostException is thrown. The host name and IP address are not validated. The hostname either be a machine alias or a valid IPv6 or IPv4 address format. The high order byte is ipAddress[0].
Parameters:
  hostName - string representation of hostname or IP address
Parameters:
  ipAddress - either a 4 (IPv4) or 16 (IPv6) byte array
Parameters:
  scope_id - the scope id for a scoped address. If not a scoped addressjust pass in 0 the InetAddress
throws:
  UnknownHostException -



getByName
public static InetAddress getByName(String host) throws UnknownHostException(Code)
Answers the address of a host, given a host string name. The host string may be either a machine name or a dotted string IP address. If the latter, the hostName field will be determined upon demand.
Parameters:
  host - the hostName to be resolved to an address InetAddress the InetAddress representing the host
throws:
  UnknownHostException - if the address lookup fails



getCanonicalHostName
public String getCanonicalHostName()(Code)
Answers canonical name for the host associated with the internet address String string containing the host name



getHostAddress
public String getHostAddress()(Code)
Answer the dotted string IP address representing this address. String the corresponding dotted string IP address



getHostByAddrImpl
native static InetAddress getHostByAddrImpl(byte[] addr) throws UnknownHostException(Code)
Query the IP stack for the host address. The host is in address form.
Parameters:
  addr - the host address to lookup
throws:
  UnknownHostException - if an error occurs during lookup



getHostByNameImpl
native static InetAddress getHostByNameImpl(String name, boolean preferIPv6Address) throws UnknownHostException(Code)
Query the IP stack for the host address. The host is in string name form.
Parameters:
  name - the host name to lookup
Parameters:
  preferIPv6Addresses - address preference if underlying platform is V4/V6 InetAddress the host address
throws:
  UnknownHostException - if an error occurs during lookup



getHostName
public String getHostName()(Code)
Answer the host name. String the corresponding string name



getHostNameImpl
native static String getHostNameImpl()(Code)
Query the IP stack for the host machine name. String the host machine name



getHostNameInternal
static String getHostNameInternal(String host) throws UnknownHostException(Code)



getLocalHost
public static InetAddress getLocalHost() throws UnknownHostException(Code)
Answer the local host, if allowed by the security policy. Otherwise, answer the loopback address which allows this machine to be contacted. InetAddress the InetAddress representing the local host
throws:
  UnknownHostException - if the address lookup fails



hashCode
public int hashCode()(Code)
Answer a hashcode for this IP address. int the hashcode



inetAddr
static int inetAddr(String host) throws UnknownHostException(Code)



inetAddrImpl
native static int inetAddrImpl(String host) throws UnknownHostException(Code)
Convert a string containing an Ipv4 Internet Protocol dotted address into a binary address. Note, the special case of '255.255.255.255' throws an exception, so this value should not be used as an argument. See also inetAddr(String).



inetNtoaImpl
native static String inetNtoaImpl(int hipAddr)(Code)
Convert a binary address into a string containing an Ipv4 Internet Protocol dotted address.



intToBytes
static void intToBytes(int value, byte bytes, int start)(Code)
Takes the integer and chops it into 4 bytes, putting it into the byte array starting with the high order byte at the index start. This method makes no checks on the validity of the parameters.



isAnyLocalAddress
public boolean isAnyLocalAddress()(Code)
Method isAnyLocalAddress. boolean



isLinkLocalAddress
public boolean isLinkLocalAddress()(Code)
Answers true if the address is a link local address. Valid IPv6 link local addresses are FE80::0 through to FEBF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF There are no valid IPv4 link local addresses. boolean



isLoopbackAddress
public boolean isLoopbackAddress()(Code)
Answer true if the address is a loop back address. Valid IPv4 loopback addresses are 127.d.d.d Valid IPv6 loopback address is ::1 boolean



isMCGlobal
public boolean isMCGlobal()(Code)
Answers true if the address is a global multicast address. Valid IPv6 link global multicast addresses are FFxE:/112 where x is a set of flags, and the additional 112 bits make up the global multicast address space Valid IPv4 global multicast addresses are between: 224.0.1.0 to 238.255.255.255 boolean



isMCLinkLocal
public boolean isMCLinkLocal()(Code)
Answers true if the address is a link local multicast address. Valid IPv6 link local multicast addresses are FFx2:/112 where x is a set of flags, and the additional 112 bits make up the node local multicast address space Valid IPv4 link-local addresses are between: 224.0.0.0 to 224.0.0.255 boolean



isMCNodeLocal
public boolean isMCNodeLocal()(Code)
Answers true if the address is a node local multicast address. Valid IPv6 node local multicast addresses are FFx1:/112 where x is a set of flags, and the additional 112 bits make up the node local multicast address space There are no valid IPv4 node local multicast addresses. boolean



isMCOrgLocal
public boolean isMCOrgLocal()(Code)
Answers true if the address is a organization local multicast address. Valid IPv6 organization local multicast addresses are FFx8:/112 where x is a set of flags, and the additional 112 bits make up the node local multicast address space Valid IPv4 organization-local addresses are between: 239.192.0.0 to 239.251.255.255 boolean



isMCSiteLocal
public boolean isMCSiteLocal()(Code)
Answers true if the address is a site local multicast address. Valid IPv6 site local multicast addresses are FFx5:/112 where x is a set of flags, and the additional 112 bits make up the node local multicast address space Valid IPv4 site-local addresses are between: 239.252.0.0 to 239.255.255.255 boolean



isMulticastAddress
public boolean isMulticastAddress()(Code)
Answer true if the InetAddress is an IP multicast address. boolean true, if the address is in the multicast group



isReachable
public boolean isReachable(int timeout) throws IOException(Code)
Tries to see if the InetAddress is reachable. This method first tries to use ICMP(ICMP ECHO REQUEST). When first step fails, the TCP connection on port 7 (Echo) shall be lauched.
Parameters:
  timeout - timeout in milliseconds true if address is reachable
throws:
  IOException - if I/O operation meets error
throws:
  IllegalArgumentException - if timeout is less than zero



isReachable
public boolean isReachable(NetworkInterface netif, int ttl, int timeout) throws IOException(Code)
Tries to see if the InetAddress is reachable. This method first tries to use ICMP(ICMP ECHO REQUEST). When first step fails, the TCP connection on port 7 (Echo) shall be lauched.
Parameters:
  netif - the network interface through which to connect
Parameters:
  ttl - max hops to live
Parameters:
  timeout - timeout in milliseconds true if address is reachable
throws:
  IOException - if I/O operation meets error
throws:
  IllegalArgumentException - if ttl or timeout is less than zero



isSiteLocalAddress
public boolean isSiteLocalAddress()(Code)
Answers true if the address is a site local address. Valid IPv6 link local addresses are FEC0::0 through to FEFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF There are no valid IPv4 site local addresses. boolean



lookupHostByName
static synchronized InetAddress lookupHostByName(String host) throws UnknownHostException(Code)



preferIPv6Addresses
static boolean preferIPv6Addresses()(Code)



toString
public String toString()(Code)
Answers a string containing a concise, human-readable description of the address. String the description, as host/address



Methods inherited from java.lang.Object
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final public Class<? extends Object> getClass()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
final public void notify()(Code)(Java Doc)
final public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final public void wait(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait(long millis) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.