Saturday, April 30, 2022

Advantages and Disadvantages of Java Sockets

Java Sockets, Oracle Java Exam Prep, Oracle Java Learning, Core Java, Java Preparation, Java Preparation

A socket is an End-Point of 2 sided or two-way communication link between two PCs running on the network. For Example: If there are two people in different places who want to communicate with each other and each of them has a mobile phone. So one of them has to start the communication by dialing the person and then the other person receives the call then the connection will be established between these two. Once, the connection is established then they can start communicating with each other by sending and accepting messages so that is how a simple mobile phone end-to-end communication works, here the mobile phones act as a socket and endpoint of communication.

How communication is done?

To communicate both devices need to have sockets at their end. Since we’re doing java programming these sockets are called java objects or socket objects. So to establish a connection and to send and receive messages and data both ends need to have a socket at the sender’s end and at the receiver’s end. Below is the illustration of the network

Java Sockets, Oracle Java Exam Prep, Oracle Java Learning, Core Java, Java Preparation, Java Preparation

How sockets are used to send and receive data?


We are going to use input and output streams 

◉ socket input streams: to read the data.
◉ socket output stream: to write the data.

Let’s say we want to send data from socket 1 to socket 2 in that case we have to use socket 1 output stream and to read data from B to A. we’ll use the socket as an input stream. Now Let’s discuss the Advantages and Disadvantages of java sockets.

Advantages and Disadvantages of Java Sockets


Advantages Disadvantages 
Flexible & powerful  Increased complexity cost and high-Security restrictions.
Very sufficient  Socket-based communications allow only to send packets of raw data between applications. 
Updated Information can be used to send only between devices  Communication can be established with the machine requested not with another machine. 
Low network traffic if efficient use  Both ends should have the ability to intercept the data. 

Source: geeksforgeeks.org

Related Posts

0 comments:

Post a Comment