SlideShare a Scribd company logo
Java API: java.net.InetAddress
    {   Ankit Gadgil: 11030142027
        Sayak Sarkar: 11030142046
The InetAddress class is the abstraction representing an IP
(Internet Protocol) address, which 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.

It has two subclasses:
Inet4Address for IPv4 addresses.

Inet6Address for IPv6 addresses.



In most cases, there is no need to deal directly with the
subclasses, as the InetAddress abstraction covers most of the
needed functionality.




The InetAddress Class
   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).

   The IP address architecture is defined by RFC 790: Assigned
    Numbers, RFC 1918: Address Allocation for Internets, RFC 2365:
    Administratively Scoped IP Multicast, and RFC 2373: IP Version
    6 Addressing Architecture.


   Class Declaration:
    public class InetAddress extends Object implements Serializable




The InetAddress Class
   This class represents an Internet Protocol version 4 (IPv4)
    address.
   It has been defined by RFC790:Assigned Numbers,
    RFC1918: Address Allocation for Private Internets, and
    RFC 2365: Administratively Scoped IP Multicast

   Class Declaration:
    public final class Inet4Address extends InetAddress




The Inet4Address Class
   This class represents an Internet Protocol version 6 (IPv6)
    address.
   It has been defined by RFC 2373: IP Version 6 Addressing
    Architecture.

   Class Declaration:
    public final class Inet6Address extends InetAddress




The Inet6Address Class
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 wildcard address, must never be
assigned to any node. It indicates the absence of an address. 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.




InetAddress: Address Types
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.




    InetAddress: Address Types
   Link-local addresses are designed to be used for addressing
    on a single link for purposes such as auto-address
    configuration, neighbor discovery, or when no routers are
    present.

   Site-local addresses are designed to be used for addressing
    inside of a site without the need for a global prefix.

   Global addresses are unique across the internet.




InetAddress: IP address scope
   Host name-to-IP address resolution is accomplished through the
     use of a combination of local machine configuration information
     and network naming services such as the Domain Name System
     (DNS) and Network Information Service(NIS).

    The particular naming services(s) being used is by default the
     local machine configured one.

    For any host name, its corresponding IP address is returned.
     Reverse name resolution means that for any IP address, the host
     associated with the IP address is returned.

    The InetAddress class provides methods to resolve host names to
     their IP addresses and vice versa.



InetAddress: Host Name Resolution
   The InetAddress class has a cache to store successful as well as
    unsuccessful host name resolutions.

   By default, when a security manager is installed, in order to protect
    against DNS spoofing attacks, the result of positive host name
    resolutions are cached forever.

   When a security manager is not installed, the default behavior is to
    cache entries for a finite (implementation dependent) period of time.

   The result of unsuccessful host name resolution is cached for a very
    short period of time (10 seconds) to improve performance.

   If the default behavior is not desired, then a Java security property
    can be set to a different Time-to-live (TTL) value for positive caching.



InetAddress: Caching
Two Java security properties control the TTL values used for
positive and negative host name resolution caching:

networkaddress.cache.ttl Indicates the caching policy for
successful name lookups from the name service. The value is
specified as integer to indicate the number of seconds to cache the
successful lookup. The default setting is to cache for an
implementation specific period of time. A value of -1 indicates
"cache forever".

networkaddress.cache.negative.ttl (default: 10) Indicates the
caching policy for un-successful name lookups from the name
service. The value is specified as integer to indicate the number of
seconds to cache the failure for un-successful lookups. A value of 0
indicates "never cache". A value of -1 indicates "cache forever".


InetAddress: Caching
Two Java security properties control the TTL values used for
positive and negative host name resolution caching:

networkaddress.cache.ttl Indicates the caching policy for
successful name lookups from the name service. The value is
specified as as integer to indicate the number of seconds to cache
the successful lookup. The default setting is to cache for an
implementation specific period of time. A value of -1 indicates
"cache forever".

networkaddress.cache.negative.ttl (default: 10) Indicates the
caching policy for un-successful name lookups from the name
service. The value is specified as integer to indicate the number of
seconds to cache the failure for un-successful lookups. A value of 0
indicates "never cache". A value of -1 indicates "cache forever".



InetAddress: Caching
 boolean              equals(Object obj)
                                Compares this object against the specified object.

 byte[]               getAddress()
                                Returns the raw IP address of this InetAddress object.

static InetAddress[] getAllByName(String host)
                               Given the name of a host, returns an array of its IP addresses, based
                     on the configured name service on the system.

static InetAddress    getByAddress(byte[] addr)
                                Returns an InetAddress object given the raw IP address .

static InsetAddress getByAddress(String host, byte[] addr)
                              Create an InetAddress based on the provided host name and IP
                    address No name service is checked for the validity of the address.

static InetAddress    getByName(String host)
                                Determines the IP address of a host, given the host's name.



  InetAddress: Methods
 String              getCanonicalHostName()
                               Gets the fully qualified domain name for this IP address.

 String              getHostAddress()
                               Returns the IP address string in textual presentation.

 String              getHostName()
                               Gets the host name for this IP address.

static InetAddress   getLocalHost()
                               Returns the local host.

 int                 hashCode()
                               Returns a hashcode for this IP address.

 boolean             isAnyLocalAddress()
                               Utility routine to check if the InetAddress in a wildcard address.




  InetAddress: Methods
 boolean   isLinkLocalAddress()
                     Utility routine to check if the InetAddress is an link local address.

 boolean   isLoopbackAddress()
                     Utility routine to check if the InetAddress is a loopback address.

 boolean   isMCGlobal()
                     Utility routine to check if the multicast address has global scope.

 boolean   isMCLinkLocal()
                     Utility routine to check if the multicast address has link scope.

 boolean   isMCNodeLocal()
                     Utility routine to check if the multicast address has node scope.

 boolean   isMCOrgLocal()
                     Utility routine to check if the multicast address has organization
           scope.




 InetAddress: Methods
 boolean   isMCSiteLocal()
                     Utility routine to check if the multicast address has site scope.

 boolean   isMulticastAddress()
                     Utility routine to check if the InetAddress is an IP multicast
           address.

 boolean   isReachable(int timeout)
                     Test whether that address is reachable.

 boolean   isReachable(NetworkInterface netif, int ttl, int timeout)
                     Test whether that address is reachable.

 boolean   isSiteLocalAddres()
                     Utility routine to check if the InetAddress is a site local address.

 String    toString()
                     Converts this IP address to a String.




  InetAddress: Methods
Thank You…

More Related Content

PPTX
graphics programming in java
PPTX
Validation Controls in asp.net
PPTX
Master page in Asp.net
PPT
Java Streams
PPTX
Event Handling in java
PPTX
Java Swing
PPTX
Data structure & its types
graphics programming in java
Validation Controls in asp.net
Master page in Asp.net
Java Streams
Event Handling in java
Java Swing
Data structure & its types

What's hot (20)

PPTX
Dynamic memory allocation
PPTX
Awt, Swing, Layout managers
PPTX
Php string function
PPT
Active x control
PDF
StringTokenizer in java
PPTX
Unit 5 java-awt (1)
PPTX
PPTX
Type casting in java
PPTX
Functions in c++
PDF
Android resources
PPTX
HTML Forms
PPTX
Constructor overloading & method overloading
PPTX
Arrays 1D and 2D , and multi dimensional
PPTX
Event Handling in JAVA
PDF
Nested Queries Lecture
PDF
Datatypes in python
PPT
Php Using Arrays
PDF
Php array
Dynamic memory allocation
Awt, Swing, Layout managers
Php string function
Active x control
StringTokenizer in java
Unit 5 java-awt (1)
Type casting in java
Functions in c++
Android resources
HTML Forms
Constructor overloading & method overloading
Arrays 1D and 2D , and multi dimensional
Event Handling in JAVA
Nested Queries Lecture
Datatypes in python
Php Using Arrays
Php array
Ad

Viewers also liked (9)

PPT
Working with color and font
PPT
URL Class in JAVA
PPT
Url Connection
PPT
PPTX
Client Server models in JAVA
PDF
Cache Sketches: Using Bloom Filters and Web Caching Against Slow Load Times
PPTX
Advance Java-Network Programming
PPTX
Network programming in java - PPT
PPT
Storage Area Network (San)
Working with color and font
URL Class in JAVA
Url Connection
Client Server models in JAVA
Cache Sketches: Using Bloom Filters and Web Caching Against Slow Load Times
Advance Java-Network Programming
Network programming in java - PPT
Storage Area Network (San)
Ad

Similar to Java API: java.net.InetAddress (20)

PPTX
CHAPTER - 3 - JAVA NETWORKING.pptx
PPTX
Advanced Java Programming: Introduction and Overview of Java Networking 1. In...
PPTX
Java networking basics & sockets overview
PPTX
Javanetworkingbasicssocketsoverview
PDF
Module 1 networking basics-2
PPTX
Networking
PPTX
Java networking
PPTX
Unit 2 : Internet Address
PPTX
3160707_AJava_GTU_Study_Material_Presentations_Unit-1_16032021121225PM.pptx
PPT
Md13 networking
PPSX
File 10 - CSX 334 _VRA NBO.ppsx
PDF
Chapter 2 : Inet Address & Data Stream
DOCX
Lab manual cn-2012-13
PPT
Java Networking
PPT
Basic socket programming
PPT
WCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...
PPT
Internet IP V6 Protocol for Networking Students
PPTX
Network address translation
DOCX
Skip to Main content.docx
PPTX
networkaddresstranslation-160909142440.pptx
CHAPTER - 3 - JAVA NETWORKING.pptx
Advanced Java Programming: Introduction and Overview of Java Networking 1. In...
Java networking basics & sockets overview
Javanetworkingbasicssocketsoverview
Module 1 networking basics-2
Networking
Java networking
Unit 2 : Internet Address
3160707_AJava_GTU_Study_Material_Presentations_Unit-1_16032021121225PM.pptx
Md13 networking
File 10 - CSX 334 _VRA NBO.ppsx
Chapter 2 : Inet Address & Data Stream
Lab manual cn-2012-13
Java Networking
Basic socket programming
WCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...
Internet IP V6 Protocol for Networking Students
Network address translation
Skip to Main content.docx
networkaddresstranslation-160909142440.pptx

More from Sayak Sarkar (7)

PDF
Firefox OS
PDF
Google summer of code
PDF
Webmaker
PDF
Sculpting a Vibrant Community - MozCamp Asia 2012
PDF
MozCarnival Pune
PDF
Mozfest Pune
PDF
MozParty Pune
Firefox OS
Google summer of code
Webmaker
Sculpting a Vibrant Community - MozCamp Asia 2012
MozCarnival Pune
Mozfest Pune
MozParty Pune

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Approach and Philosophy of On baking technology
PPTX
MYSQL Presentation for SQL database connectivity
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
A Presentation on Artificial Intelligence
PPTX
Big Data Technologies - Introduction.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
20250228 LYD VKU AI Blended-Learning.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
Approach and Philosophy of On baking technology
MYSQL Presentation for SQL database connectivity
A comparative analysis of optical character recognition models for extracting...
Machine learning based COVID-19 study performance prediction
A Presentation on Artificial Intelligence
Big Data Technologies - Introduction.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
Programs and apps: productivity, graphics, security and other tools
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

Java API: java.net.InetAddress

  • 1. Java API: java.net.InetAddress { Ankit Gadgil: 11030142027 Sayak Sarkar: 11030142046
  • 2. The InetAddress class is the abstraction representing an IP (Internet Protocol) address, which 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. It has two subclasses: Inet4Address for IPv4 addresses. Inet6Address for IPv6 addresses. In most cases, there is no need to deal directly with the subclasses, as the InetAddress abstraction covers most of the needed functionality. The InetAddress Class
  • 3. 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).  The IP address architecture is defined by RFC 790: Assigned Numbers, RFC 1918: Address Allocation for Internets, RFC 2365: Administratively Scoped IP Multicast, and RFC 2373: IP Version 6 Addressing Architecture.  Class Declaration: public class InetAddress extends Object implements Serializable The InetAddress Class
  • 4. This class represents an Internet Protocol version 4 (IPv4) address.  It has been defined by RFC790:Assigned Numbers, RFC1918: Address Allocation for Private Internets, and RFC 2365: Administratively Scoped IP Multicast  Class Declaration: public final class Inet4Address extends InetAddress The Inet4Address Class
  • 5. This class represents an Internet Protocol version 6 (IPv6) address.  It has been defined by RFC 2373: IP Version 6 Addressing Architecture.  Class Declaration: public final class Inet6Address extends InetAddress The Inet6Address Class
  • 6. 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 wildcard address, must never be assigned to any node. It indicates the absence of an address. 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. InetAddress: Address Types
  • 7. 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. InetAddress: Address Types
  • 8. Link-local addresses are designed to be used for addressing on a single link for purposes such as auto-address configuration, neighbor discovery, or when no routers are present.  Site-local addresses are designed to be used for addressing inside of a site without the need for a global prefix.  Global addresses are unique across the internet. InetAddress: IP address scope
  • 9. Host name-to-IP address resolution is accomplished through the use of a combination of local machine configuration information and network naming services such as the Domain Name System (DNS) and Network Information Service(NIS).  The particular naming services(s) being used is by default the local machine configured one.  For any host name, its corresponding IP address is returned. Reverse name resolution means that for any IP address, the host associated with the IP address is returned.  The InetAddress class provides methods to resolve host names to their IP addresses and vice versa. InetAddress: Host Name Resolution
  • 10. The InetAddress class has a cache to store successful as well as unsuccessful host name resolutions.  By default, when a security manager is installed, in order to protect against DNS spoofing attacks, the result of positive host name resolutions are cached forever.  When a security manager is not installed, the default behavior is to cache entries for a finite (implementation dependent) period of time.  The result of unsuccessful host name resolution is cached for a very short period of time (10 seconds) to improve performance.  If the default behavior is not desired, then a Java security property can be set to a different Time-to-live (TTL) value for positive caching. InetAddress: Caching
  • 11. Two Java security properties control the TTL values used for positive and negative host name resolution caching: networkaddress.cache.ttl Indicates the caching policy for successful name lookups from the name service. The value is specified as integer to indicate the number of seconds to cache the successful lookup. The default setting is to cache for an implementation specific period of time. A value of -1 indicates "cache forever". networkaddress.cache.negative.ttl (default: 10) Indicates the caching policy for un-successful name lookups from the name service. The value is specified as integer to indicate the number of seconds to cache the failure for un-successful lookups. A value of 0 indicates "never cache". A value of -1 indicates "cache forever". InetAddress: Caching
  • 12. Two Java security properties control the TTL values used for positive and negative host name resolution caching: networkaddress.cache.ttl Indicates the caching policy for successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the successful lookup. The default setting is to cache for an implementation specific period of time. A value of -1 indicates "cache forever". networkaddress.cache.negative.ttl (default: 10) Indicates the caching policy for un-successful name lookups from the name service. The value is specified as integer to indicate the number of seconds to cache the failure for un-successful lookups. A value of 0 indicates "never cache". A value of -1 indicates "cache forever". InetAddress: Caching
  • 13.  boolean equals(Object obj)           Compares this object against the specified object.  byte[] getAddress()           Returns the raw IP address of this InetAddress object. static InetAddress[] getAllByName(String host)           Given the name of a host, returns an array of its IP addresses, based on the configured name service on the system. static InetAddress getByAddress(byte[] addr)           Returns an InetAddress object given the raw IP address . static InsetAddress getByAddress(String host, byte[] addr)           Create an InetAddress based on the provided host name and IP address No name service is checked for the validity of the address. static InetAddress getByName(String host)           Determines the IP address of a host, given the host's name. InetAddress: Methods
  • 14.  String getCanonicalHostName()           Gets the fully qualified domain name for this IP address.  String getHostAddress()           Returns the IP address string in textual presentation.  String getHostName()           Gets the host name for this IP address. static InetAddress getLocalHost()           Returns the local host.  int hashCode()           Returns a hashcode for this IP address.  boolean isAnyLocalAddress()           Utility routine to check if the InetAddress in a wildcard address. InetAddress: Methods
  • 15.  boolean isLinkLocalAddress()           Utility routine to check if the InetAddress is an link local address.  boolean isLoopbackAddress()           Utility routine to check if the InetAddress is a loopback address.  boolean isMCGlobal()           Utility routine to check if the multicast address has global scope.  boolean isMCLinkLocal()           Utility routine to check if the multicast address has link scope.  boolean isMCNodeLocal()           Utility routine to check if the multicast address has node scope.  boolean isMCOrgLocal()           Utility routine to check if the multicast address has organization scope. InetAddress: Methods
  • 16.  boolean isMCSiteLocal()           Utility routine to check if the multicast address has site scope.  boolean isMulticastAddress()           Utility routine to check if the InetAddress is an IP multicast address.  boolean isReachable(int timeout)           Test whether that address is reachable.  boolean isReachable(NetworkInterface netif, int ttl, int timeout)           Test whether that address is reachable.  boolean isSiteLocalAddres()           Utility routine to check if the InetAddress is a site local address.  String toString()           Converts this IP address to a String. InetAddress: Methods