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.
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. Very soon you need to expand your business and you felt the requirement to add more people as well more computers.
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. In a Client/server architecture individual computers (known as clients) are connected to a central computer which is known as ?server?.
3. Sockets and Ports
In this section we are going to explain the work of sockets in more generic way by the appropriate examples. Here we are going to describe, how to use sockets in our programs to communicate with other programs on the network. In the network environment a socket can be considered as the endpoint of a two-way communication link between two programs. At the end of the section you also able to work with socket e.g. how do we connect a client to a standard server, the Echo and communication with server via a socket and much more.
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. In java there is a java.net package, which provides two types of classes- first is ordinary socket, which implement the client side connection and second is server socket, which implement the server side connection.
5. 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. In this section we will provide the complete information about the way of using URL in java network programming through a full code-example. The example give you the full exposure to network programming e.g. how to open a connection to a URL, how to retrieve information of a given URL.
6. Use Datagram in Network Environment
A datagram is just like a message
sent over the network. It is use to communicate and transmit the data between
clients and servers through reliable channel, such as a TCP socket. The drawback
of the datagram is the delivery of datagrams to their destinations is not
guaranteed. Mainly there are three classes named DatagramSocket, DatagramPacket,
and MulticastSocket
in the java.net package that use the datagram to send and receive
packet over the network.
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.
Here we explain some example that shows the proper use for communicate with client/server in the network environment. We also give some examples of how to list all the IP addresses assigned to the machine and many more.