ChatServer using User Datagram protocol(UDP) in Python

Himanshu Agrawal
3 min readMar 6, 2021

--

Hello Guys ,

In this practical we will create a chat server using Python . The Description of Practical or Task is given below .

Task Description📄 -

  • 🔅 Create your own Chat Servers, and establish a network to transfer data using Socket Programing by creating both Server and Client machine as Sender and Receiver both. Do this program using UDP data transfer protocol.
  • Note: Machines must have different OS like One Linux Machine one Windows. Both machines must be configured with python.

Socket Programming:-

Sockets can be thought of as endpoints in a communication channel that is bi-directional, and establishes communication between a server and one or more clients.
The socket on the server side associates itself with some hardware port on the server side. Any client that has a socket associated with the same port can communicate with the server socket.

let’s take a closer look at the interaction between two communicating processes that use UDP sockets:-

Before the sending process can push a packet of data out of the socket, when using UDP, it must first attach a destination address to a packet. After the packet passes through the sender’s socket, the internet will use this destination address to route the packet through the internet to the socket in the receiving process. When the packet arrives at the receiving socket, the receiving process will retrieve the packet through the socket, and then inspect the packet’s contents and take appropriate action.

UDP sockets:-

UDP is a connection-less and non-stream oriented protocol. It means a UDP server just catches incoming packets from any and many hosts without establishing a reliable pipe kind of connection.

Let’s view the connections

For the practical I would be using two systems. One is Windows 10 and the other is RHEL8.

Here is the code for the client side of the application:

Let’s now take a look at the server side of the application:

Demo Of Chatting-

I have successfully created a server which help us to do chatting between two systems .

--

--