Coders Packet

Program in Java for Simplex Communication using Connection Oriented Service

By Purnima Agarwal

This program implements simplex communication using connection-oriented services where SocketServer and Socket class is used. This is a Socket Programming concept in Computer Networks.

Java Socket Programming is used for communication between different applications or ports.

For connection-oriented socket programming, we use Socket and SocketServer classes, and for connectionless socket programming, we use DatagramSocket and DatagramPacket classes.


The package we use is It contains all the classes we will need for Socket Programming in Java.

In a computer network, communication is done between server and client.

There are three modes of transmission:

1) Simplex Communication: In simplex communication, data transmission takes place in one direction only and from one side only.

2) Half Duplex Communication: In half-duplex, data transmission happens from both side but not at the same time.

3) Ful Duplex Communication: In half-duplex, data transmission happens from both and at the same time.


Here we have implemented Simplex Communication.



On the server-side:

1) Establishing Connection

2) Listen to the Client request

3) Give Response

4) Close the connection

First, we create an object of the ServerSocket class and wait for the client's request. We create an I/O stream for communicating to the client using BufferedReader class and getOutputStream() method is used to send the output through the socket.

On the client-side:

1) Establish connection

2) Send a request

3) Close the connection

We create a Socket object and an I/O stream for communication and after receiving the result we close the connection.


We pass two values to the client for communication:

  1. IP Address of Server, and
  2. Port number.


We first run the server code and then the client code.

Download Complete Code


No comments yet