Chat Servers Using Multi-threading

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.

Thank you for reading!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store