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.tutorialsinfo.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 address types: 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. Commonly used methods of InetAddress class
Example of Java InetAddress classLet's see a simple example of InetAddress class to get ip address of www.tutorialsinfo.com website. Output: Host Name: www.tutorialsinfo.com IP Address: 206.51.231.148 Next TopicDatagramSocket And DatagramPacket
|