Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Advantages and Disadvantages of Java Sockets

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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





Flexible & powerfulIncreased complexity cost and high-Security restrictions.


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


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


Low network traffic if efficient useBoth ends should have the ability to intercept the data.
My Personal Notes arrow_drop_up
Last Updated : 29 Apr, 2022
Like Article
Save Article
Similar Reads
Related Tutorials