Network is the concept of connecting several remote or local devices together. The Java program communicates through the network in the application layer.
All classes and interfaces of Java networks use the java.net package. These classes and interfaces provide the functionality to develop network communication independent of the system.
The java.net package provides functionality for two common protocols:
TCP (Transmission Control Protocol)
TCP is a connection-based protocol that provides a reliable flow of data between two devices. This protocol provides trusted connections between two applications so they can communicate easily. It is a connection-based protocol.
UDP (User Datagram Protocol)
The UDP protocol sends independent data packets, called datagrams from one computer to another, with no guarantee of arrival. It is not a connection-based protocol.
Advantage of Java Networking
- Sharing resources
- Centralize software management
Java network terminology
The widely used java network terminologies are given below:
- IP address
- Port number
- MAC address
- Protocol oriented to the connection and without connection
1) IP address
The IP address is a unique number assigned to a node in a network, for example. 192.168.0.1. It consists of octets that vary from 0 to 255.It is a logical address that can be changed.
A protocol is basically a set of rules followed for communication. For example:
3) Port number
The port number is used to uniquely identify different applications. It acts as a final point of communication between the applications.
The port number is associated with the IP address for communication between two applications.
4) MAC Address
MAC (Media Access Control) The address is a unique identifier of the NIC (Network Interface Controller). A network node can have several NICs, but each with exclusive MAC.
5) Protocol oriented to the connection and without connection
In the connection-oriented protocol, the acknowledgment is sent by the receiver. Therefore, it is reliable, but slow. The example of a connection-oriented protocol is TCP.
But in the protocol without connection, the recognition is not sent by the receiver. Therefore, it is not trustworthy, but fast. The protocol example without connection is UDP.
Interested in learning Java? Enroll now:” Java training in Chennai “
The sockets provide the communication mechanism between two computers through TCP. A client program creates a socket at the end of the communication and tries to connect this socket to a server.
When the connection is made, the server creates a socket object at the end of the communication. The client and the server can now communicate by recording and reading from the socket.
The java.net.Socket class represents a socket and the java.net.ServerSocket class provides a mechanism for the server program to listen to clients and establish connections with them.
To getting expert-level training for Java Training in your location – java training in Chennai | java training in Bangalore | java training in Pune | java training in Chennai | java training in Bangalore | java training in Chennai | java interview questions and answers | core java interview questions and answers | java training in Chennai | For getting java online training | java online training