From 2b0eb83ff6eb465f933d89ee4e6e1569d65db36c Mon Sep 17 00:00:00 2001 From: "Andre Silva (mateussa)" Date: Wed, 22 Nov 2017 08:24:17 +0000 Subject: [PATCH] Simplified receiveMessage function Don't need two while loops that are the same, run the while loop and check if needs to send the "EndOfMEssage" after --- Server.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Server.py b/Server.py index dc762cf..bca400b 100644 --- a/Server.py +++ b/Server.py @@ -8,17 +8,12 @@ def sendMessage(message, EOM = True): # Andre ''' Given a message input, and a False value, send the message and the client keeps wayting for another message ''' resp = "" + while (resp != "Received"): # If client doesn't receive message, send again + conn.send(str(message).encode()) + print("SERVER: {}".format(message)) + resp = conn.recv(1024).decode() # Waits for client feedback if (EOM): - while (resp != "Received"): # If client doesn't receive message, send again - conn.send(str(message).encode()) - print("SERVER: {}".format(message)) - resp = conn.recv(1024).decode() # Waits for client feedback conn.send("EndOfMessage".encode()) - else: - while (resp != "Received"): # If client doesn't receive message, send again - conn.send(str(message).encode()) - print("SERVER: {}".format(message)) - resp = conn.recv(1024).decode() # Waits for client feedback def receiveMessage(): # Andre ''' Receive a message from the client and check if received correctly,