java.net.InetAddress Class in Java
public class InetAddress extends Object implements Serializable:
The java.net.InetAddress class provides methods to get the IP address of any hostname. An IP address is represented by 32-bit or 128-bit unsigned number. InetAddress can handle both IPv4 and IPv6 addresses.
There are 2 types of addresses :
Unicast — An identifier for a single interface.
Multicast — An identifier for a set of interfaces.
This class represents an Internet Protocol (IP) address.
An IP address is either a 32-bit or 128-bit unsigned number used by IP, a lower-level protocol on which protocols like UDP and TCP are built. The IP address architecture is defined by RFC 790: Assigned Numbers, RFC 1918: Address Allocation for Private Internets, RFC 2365: Administratively Scoped IP Multicast, and RFC 2373: IP Version 6 Addressing Architecture. An instance of an InetAddress consists of an IP address and possibly its corresponding host name (depending on whether it is constructed with a host name or whether it has already done reverse host name resolution).
Address types
1-unicast An identifier for a single interface. A packet sent to a unicast address is delivered to the interface identified by that address.
The Unspecified Address -- Also called anylocal or wildcard address. It must never be assigned to any node. It indicates the absence of an address. One example of its use is as the target of bind, which allows a server to accept a client connection on any interface, in case the server host has multiple interfaces.
The unspecified address must not be used as the destination address of an IP packet.
The Loopback Addresses -- This is the address assigned to the loopback interface. Anything sent to this IP address loops around and becomes IP input on the local host. This address is often used when testing a client.
2-multicast:An identifier for a set of interfaces (typically belonging to different nodes). A packet sent to a multicast address is delivered to all interfaces identified by that address.
On this page of the site you can watch the video online 2-InetAddress in Java | Network &Distributed Systems with a duration of hours minute second in good quality, which was uploaded by the user Professional Skill 2023 22 March 2025, share the link with friends and acquaintances, this video has already been watched 28 times on youtube and it was liked by 2 viewers. Enjoy your viewing!