rendered paste body# Server program
from socket import *
from Tkinter import *
root = Tk()
# Set the socket parameters
host = ''
port = 5154
buf = 1024
addr = (host,port)
chat = Text(root, font="times", width="50", height="20", background="#FFFFFF", foreground="#000000", borderwidth="2", bd="2")
chat.pack()
# Create socket and bind to address
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(addr)
# Receive messages
while 1:
data,addr = UDPSock.recvfrom(buf)
chat.insert(INSERT, data+"\n")
root.after(10, show)
# Close socket
root.after(10, show)
root.mainloop()
UDPSock.close()