Table of Contents
A network is defined as a collection of systems that are connected to one another. The best example of a network is the World Wide Web or the Internet as we know if it. It initially started as a network of connected computers in a locality. As the network increased in size, more data was available to users and today the entire world is connected. Network programs are those programs that can run on any machine (computer), provided all the devices are connected to a common network.
Java allows users to create network programs. The java.net package contains several classes and interfaces to facilitate the process. This package is part of the J2SE API and focuses on low-level communication details.
To communicate inside a network, certain sets of protocols are required. The java.net package provides comprehensive support for two protocols:
- TCP – Transmission Control Protocol is one of the most common protocols used for communications in networks including the Internet. When interacting between Java programs across a network, TCP is preferred over IP (Internet Protocol).
- UDP – UDP stands for User Datagram Protocol. This is a connectionless protocol where data is transmitted across devices and applications through data packets of varying lengths.
Features of Network Programming
- Socket Programming – Socket Programming is the method of using sockets to communicate between two computers over a common network. The protocol used here is TCP. When an application has been shared over a network, the client tries to establish a socket on its end and connect it to the server. Once the connection has been made, the server creates a socket object. Now this object becomes the primary mode of communication between the client and the server.
- URL Processing – As suggestive from the name, this deals with URL (Uniform Resource Locator) manipulation.