Skip to content
Permalink
Browse files

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
  • Loading branch information
mateussa committed Nov 22, 2017
1 parent a43b86e commit 2b0eb83ff6eb465f933d89ee4e6e1569d65db36c
Showing with 4 additions and 9 deletions.
  1. +4 −9 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,

0 comments on commit 2b0eb83

Please sign in to comment.
You can’t perform that action at this time.