Home Java Network Overview of Networking through JAVA
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Overview of Networking through JAVA

Advertisement
The Java platform is extremely preferable to write an application program require to communicate with the resources on network.

Overview of Networking through JAVA

     

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.

Java networking 

  • Computer Networking
    Here we are going to unfold the concepts of networking in day to day scenarios. Let us consider that you started a commercial activity where you were using a computer along with a printer, modem and a CD-ROM. 
      
  • Client-Server Architecture
    Client-server architecture can be considered as a network environment that exchanges information between a server machine  and a client machine where server has some resources that can be shared by different clients.
        
  • Socket and ports
    In common language we can say that the socket is one of the most primal technologies of computer networking. Sockets are just like an end-point of two-way communication, which allow applications to communicate using network hardware and operating systems.
       
  • Server Sockets
    In common language we can say that the sockets are just like an end-point of two-way communication link over the network between two programs. Socket classes are used to establish a connection between client program and a server program.
       
  • URL in term of Java Network Programming
    A URL (Uniform Resource Locator) is the address of a resource on the Internet. In java network programming we can use URLs to connect and retrieve information over the Internet.
      
  • Datagrams in network environment
    In a network environment the client and the server communicate with each-other by reliable channel like TCP socket which have dedicated point-to-point channel between client and server. All data sent over the channel is received and sent in the same order. 
       
  • Networking in java
    In this section we are exploring the java.net package which provides the support for networking in java with a generic style. All the java classes for developing a network program are defined in the java.net package. 

   
Getting Hands-on Java  Networking example  

  1. 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. 
            

  2. 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.   
       
      

  3. 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.
           

  4. 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.
             

  5. 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.
            

  6. 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.
             

  7. 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".       
       

  8. 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. 
        

  9. 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.     
          

  10. 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().
       

  11. 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.
             

  12. 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.
         

  13. 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.
           

  14. Getting Image from a URL
    This example shows how to get an image from the given URL.
          

  15. URLInformation
    Here we are going to explain the method to find out the URL information. This program defines the IOException for the exception handling. This exception is thrown to indicate an I/O problem.
           

  16. GetHTTPHeader
    In this section, you will learn how to get content-length, content- type, and last-modify date of a file. Here we provide a complete example that uses getHeaderFieldKey() method.
       

  17. EncoderTest
    This is a simple program of java network and supports the java.net package. Here, we have defined the class named EncoderTest.java. This class contains static methods for converting a String to the application-urlencoded MIME format.
       

  18. EchoClientSocket
    In this section, we are going to explain the method to find out the hostname port number of a local machine. This program defines the IOException for the exception handling.
        

  19. Client Socket Information
    In this section, you will learn how to get client socket information. This is a very simple program of java network. Here, we have used the class named ClientSocketInformation.java that implement the constructor of the Socket class passing two arguments as hostName and TIME_PORT.
       

  20. GetKeepAlive
    In this section, you will show the used of several method for different output massage. Here, we provide a complete example based on the method for creating the Socket() method.
      

  21. ReadIPAddress
    Here, we are going to explore a method to retrieve the IPAddress of the local system in a very simple example.
    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.
        

  22. Local Port Scanner
    This is a simple program of java network. Here, we are going to define class named "LocalPortScanner" in which we use ServerSocket class of  java.net package which takes local port number as argument. 

       

  23. Low port Scanner 
    In this section, you will learn how to get local port number of the local machine. Here, we define the name of program LowPortScanner. In this we check the argument and create a socket object.
           

  24. URL Connection Reader
    In this section, you will learn about the url connection reader. Here, first of all we are going to define class named "URLConnectionReader". After that we make a URL object passing a url "http://www.javajazzup.com" as string in its constructor. 
         

  25. URL Reader File
    This is a simple program of java network. In this section, you will learn how to read HTML file. Here, we create a URL object and pass a url. After that, we call the URL?s openStream() method to get a stream from which the contents of the URL can be read.
     

  26. RMI Client And RMI Server Implementation
    The RMI application comprises of the two separate programs, a server and a client. A typical server program creates some remote objects, makes references to these objects accessible, and waits for clients to invoke methods on these objects.
      
       
           

 

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 12, 2009

Ask Questions?    Discuss: Overview of Networking through JAVA   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
K.Mahindra
March 27, 2011
java networking using swings concept

how to connect two systems in network using swing application
nagendra
April 13, 2011
core java

in java program how to referance this keyword to jvm
malarmathi
July 9, 2012
computer network

socket
kumar
September 2, 2013
java program for Sniffer

I need simple sniffer program
DMCA.com