Simple ChatApp using UDP in python

import socket
import threading
def server():
s= socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
ip="192.168.43.222"
port=1235
s.bind((ip,port))
while True:
mrecv=s.recvfrom(1024)
text=mrecv[0].decode()
print("Massage Recieved: ",text)

def client():
s= socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
while True:
msend=input()
print("Massage Sent: ",msend)
s.sendto(msend.encode(),("192.168.43.109",1234))



t1=threading.Thread( target=client )
t2=threading.Thread( target=server)
t1.start()
t2.start()
import socket
import threading
def server():
s= socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
ip="192.168.43.109"
port=1234
s.bind((ip,port))
while True:
mrecv=s.recvfrom(1024)
text=mrecv[0].decode()
print("Massage Recieved: ",text)

def client():
s= socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
while True:
msend=input()
print("Massage Sent: ",msend)
s.sendto(msend.encode(),("192.168.43.222",1235))



t1=threading.Thread( target=server )
t2=threading.Thread( target=client)
t1.start()
t2.start()

--

--

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