Chat Servers Using Multi-threading

Abhiroop Bas
Jan 9, 2021

--

Chat Servers

Requirements

Two Operating Systems to act as Client Server and Host Server. These severs be fed with a python code to communicate with each other. Using the concept of multi-threading, the python code runs simultaneously in both the systems.

Code

import socket
import threading
import os

s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)

ip = “13.126.199.236”
port = 3000
s.bind( (ip,port) )

def t():
while True:
msg=input()
s.sendto(msg.encode(),(“13.126.199.236”,3000))
x=s.recvfrom(1024)
data=x[0]
print(“linux : “+data.decode())

t1 = threading.Thread(target = t)
t2 = threading.Thread(target = t)
t3 = threading.Thread(target = t)
t1.start()
t2.start()
t3.start()

Visit https://github.com/abhiroopbasak/python/blob/master/chat_server for more information.

client side
server side

Thank you for reading!

--

--