Here everyone,
In today's blog, we will create a Chat Server, establish a network to transfer data using Socket Programing by creating both Server and Client machines as Sender and Receiver both and I have created this program using UDP protocol.
Here we will be using Windows OS and Linux OS for the demonstration purpose.
Before we get started we should know about what is UDP Protocol and Socket Programming
UDP Protocol:
User Datagram Protocol (UDP) is one of the core members of the Internet protocol suite. With UDP, computer applications can send messages, in this case, referred to as datagrams, to other hosts on an (IP) network. UDP uses a simple connectionless communication model with a minimum of protocol mechanisms. UDP provides checksums for data integrity, and port numbers for addressing different functions at the source and destination of the datagram.
Socket programming:
Socket programming is a way of connecting two nodes on a network to communicate with each other. One socket(node) listens on a particular port at an IP, while the other socket reaches out to the other to form a connection.
And to create a chat app we will be using the concept of multi-threading so that we can send and receive the messages at the same time. So what is multi-threading?
Multi-threading:
In computer architecture, multithreading is the ability of a (CPU) to provide multiple threads of execution concurrently, supported by the operating system.
Now we know everything that is required to understand this demonstration so let's get started:
First let's create a Socket Program for the Windows
Write this code in the window OS and provide the window system IP in the System IP mentioned as a comment.
Now create a Socket programming for the Linux
Write this code on the Linux OS and provide the Linux system Ip in the System Ip that is mentioned as a comment.
Run the Widows system code
when you will run the windows system code it will ask for a receiver IP and in our case receiver is a Linux system so we need to provide the Linux system IP to it.
The same goes for the windows system.
And now start chatting, so that's how we can create a chat app using the UDP Protocol.
Thank you!!
Top comments (0)