The Java platform is extremely preferable to write an application program require to communicate with the resources on network. Java, mainly focuses on the networking relating the description of the networking capabilities of the Java platform and second one is describes a brief summary of networking in a very simple manner that how to use URLs, sockets, and datagrams.
In Java, there is a java.net package provides the network support. All the classes for making a network program are define in the java.net package. Through TCP we can communicate over the network.
Getting Hands-on Java Networking example
Find Your Host Name/IP Address
In this section you will learn about the getLocalHost()
method to print the Host name as well as the IP Address of the local system. For
do for the same we have to call InetAddress class then we need to create a
object, in which we store the local host information.
Find Your Host Name
Here we are going to explore a method to retrieve the
host name of the local system in a very simple example. Here we are just call
the InetAddress class and after made a object of that class we call a getLocalHost() method and pass it in the object.
Getting list of Local Interfaces on a machine
Here we are going to explain the method to find out the
total no of list of local interfaces available on a machine. Here we are give a
complete example named URLDemo.java.
Getting the Local port
In
this section you will learn that how a user can access the Local port.
Here we are going to make it easier to
understand the step be step process by the complete example on this topic.
Find the Host name in reverse of given IP address
In this section you will learn to
retrieve the information about the local host name using the getHostName()
method. Here is an example that provides the usage of
the getHostName() method in more detail.
How to retrieve URL information
Here we are going to explain a method for retrieve all
the network information for a given URL. In the given below example we use the
URL class and make a object.
Convert URI to URL
Here we are going to explain the method to change
Uniform Resource Identifier (URI) reference to uniform resource locator (URL). Here we are give a
complete example named "ConvertURItoURL.java".
To retrieve the IP address from Host Name, vice-versa
Here we are going to explain the method to find out the
IP address from host name and to vice verse. Here we are give a
complete example named HostLookup.java. In which we call a InetAddress and make
a object and pass the input value in it.
Construct a DatagramPacket to receive data
In this section we provide a complete code of a example
based on the method DatagramPacket(buffer, buffer.length) for
constructs a DatagramPacket for receiving packets of length length in
more generic way.
Construct a DatagramSocket on an unspecified port
In this section we are going to explain the process to
construct a DatagramPacket object in more generic way. Here we provide a
complete example based on the method for creating the DatagramSocket object
via DatagramSocket().
Return the MIME Header
In this section you will learn about the method to
retrieve the MIME header. MIME is stands for Multipurpose Internet Mail
Extensions which is an Internet Standard that extends the format of e-mail to
support. A container for MimeHeader objects, which represent the MIME headers
that is present in a MIME part of data.
Open a URLConnection to specific website address
Here we are going to establish a connection to a
specific web address via a complete example. In the example we create a class
getURLConnection and initialize a variable of url to URL and ucon of
URLConnection.
Print the URL of a URLConnection
In this section we are going to describe, how to
retrieve the value of the URL assign to the url object. Here is the complete code
of the program in which first of all we establish a connection then display it.
|
Recommend the tutorial |
Ask Questions? Discuss: Overview of Networking through JAVA
Post your Comment