Skip to main content

Command Palette

Search for a command to run...

UDP based chat application in Python

Published
•2 min read•View as Markdown
UDP based chat application in Python
S

I am a learner who likes to get behind the new technologies of the world and integrate them for a more efficient workflow. Currently learning AWS, GitOps, Kubernetes, and much more...

Hi there! Today we are going to create a UDP-based chat application in python. This is a small task. The modules we are going to use in it are :

  • Threading - for multithreading capabilities
  • Socket - for socket programming

Let's start

For this practical, we need 2 machines and in this demo, I am using my windows machine and my one virtual machine running with Linux distro.

The above module should be installed on your system. To check this you can use

pip list

If you haven't installed these modules then you can install them using

pip install <module_name>

Now we will write our python script for the chat application. I have already written it which looks like this

Screenshot (1147).png

We need to create the same files in both the system and put the respective IP in the code as said in it. Now all that's left is to test the code and see how it is working.

To run the code we use the command

python <filename>

Screenshot (1145).png

As you can see it is working fine but if you observe carefully you will notice that some data hasn't been received by the machines which is the con of UDP protocol as it is unreliable in data transfer. Thus we use TCP instead of UDP in critical operations related to the data transfer

That's it for this one. It was a short one. See you next time... !!

More from this blog

Written Wisdom

35 posts

I'm a 22-year-old boy with a passion to learn about the DevOps Landscape. I love to explore things and deep dive into how these little pieces of code come together to form such state-of-the-art tools.