Skip to content
Related Articles

Related Articles

Advantages and Disadvantages of Java Sockets

View Discussion
Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 29 Apr, 2022

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 Illustration

 

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

S.NO  

Advantages

Disadvantages

1

Flexible & powerful Increased complexity cost and high-Security restrictions.

2

Very sufficient Socket-based communications allow only to send packets of raw data between applications.

3

Updated Information can be used to send only between devices Communication can be established with the machine requested not with another machine.

4

Low network traffic if efficient use Both ends should have the ability to intercept the data.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!