Hi,
I'm writing a simple echo/chat GUI server using wxPython. I made a separate thread for the server. The only problem I have is that when I try to close the server it hangs in socket.recv() thus hanging the whole thread. How can stop the socket from receiving from the GUI thread?
Thanks
PS: here is the socket thread:
class echoThread(threading.Thread):
#---------socket variables |
#------------------------- |
backlog = 5
size = 1024
def run(self):
# while running==1:
global client
global server
server.bind ( ( '', 5000 ) )
server.listen ( 5 )
client, address = server.accept()
while client:
data = client.recv(1024)
if data:
if mainFrame.setecho.IsChecked():
client.send(data)
mainFrame.console.AppendText(data)