Feb-18-2019, 01:51 AM
I have 2 python scripts performing messaging over socket connection. It works fine via CLI however I am now trying to display the receiver end data message via tkinter in a messagebox. My problem is when the message is received I dont know how to break the while loop when pressing OK on the messagebox. I also need to make sure the incoming socket connection is not interrupt, ie- after closing the messagebox the receiver waits for the next incoming message.
Python code at receiver end :
Python code at receiver end :
# Save as server.py # Message Receiver import os from socket import * import tkinter as tk import tkinter.messagebox root = tk.Tk() host = "" port = 13000 buf = 1024 addr = (host, port) UDPSock = socket(AF_INET, SOCK_DGRAM) UDPSock.bind(addr) print ("Waiting to receive messages...") (data, addr) = UDPSock.recvfrom(buf)\ while True: tkinter.messagebox.showinfo('Duress Message', data)