Java InetAddress classJava InetAddress class represents an IP address. The java.net.InetAddress class provides methods to get the IP of any host name for example www.javatpoint.com, www.google.com, www.facebook.com, etc. An IP address is represented by 32-bit or 128-bit unsigned number. An instance of InetAddress represents the IP address with its corresponding host name. There are two types of addresses: Unicast and Multicast. The Unicast is an identifier for a single interface whereas Multicast is an identifier for a set of interfaces. Moreover, InetAddress has a cache mechanism to store successful and unsuccessful host name resolutions. IP Address
There are two versions of IP address: 1. IPv4IPv4 is the primary Internet protocol. It is the first version of IP deployed for production in the ARAPNET in 1983. It is a widely used IP version to differentiate devices on network using an addressing scheme. A 32-bit addressing scheme is used to store 232 addresses that is more than 4 million addresses. Features of IPv4:
2. IPv6IPv6 is the latest version of Internet protocol. It aims at fulfilling the need of more internet addresses. It provides solutions for the problems present in IPv4. It provides 128-bit address space that can be used to form a network of 340 undecillion unique IP addresses. IPv6 is also identified with a name IPng (Internet Protocol next generation). Features of IPv6:
TCP/IP Protocol
Java InetAddress Class Methods
Example of Java InetAddress ClassLet's see a simple example of InetAddress class to get ip address of www.javatpoint.com website. InetDemo.java Test it NowOutput: Host Name: www.javatpoint.com IP Address: 172.67.196.82 Program to demonstrate methods of InetAddress classInetDemo2.java Output: In the above Java code, the various boolean methods of InetAdress class are demonstrated. Next TopicDatagramSocket And DatagramPacket |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India