def mainLoop():
global client_sock, server_sock, channel, address
try:
while 1:
data = client_sock.recv(1024)
print "Request", data
readAndSendFrame()
except:
e = sys.exc_info()
print "Error"
print e
server_sock.close()
client_sock.close()
setupSocketServer()
listernSocket()
mainLoop()
It should be possible to put the whole try-except inside the while loop. Easy fix, but needs testing.