Arth2020 Task17
In this article we are going to create chat program using python socket programming and Threading.
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.
?? Use multi-threading concept to get and receive data parallelly from both the Server Sides. Observe the challenges that you face to achieve this using UDP.
Prerequisite
- we need two system, one for server and another for client. I have used one Redhat 8 OS and one Windows OS respectively.
- In both the system python should be install.
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 other socket reaches out to the other to form a connection. Server forms the listener socket while client reaches out to the server.
Lets begin...?.
Step 1:- Run ifconfig enp0s8 to see the ip address of Redhat 8 OS.
Step 2:- Run ipconfig to see the IP address of Windows OS.
Step 3 :-
Create one file in Redhat 8 OS name as server.py and create another file in Windows OS name as clientA.py .
Step 4:- write the code for server side python program for socket programming.
- In the above image I have imported two module socket and Thread.
- I have provided the RedHat IP in the serverip varible and Windows IP in ip variable.
- Note:- In Windows OS, socket programming run on port no 10048 and in Redhat OS we can give any IP address.
- Then I have created two Thread so that we can send and receive message parallelly.
Step5:- write the code for client side python program for socket programming.
- Above code is approximately same as the server side code only difference is in the s.bind section.
Step 6:- Now lets run both the python file.
Now chat server is created we can use this for chatting.
Its done...
Student at ARTH - The School of Technologies
4 年Thanks for sharing ??