File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -24,11 +24,14 @@ def client(msg, log_buffer=sys.stderr):
2424 # of 16-byte chunks. Accumulate the chunks you get to build the
2525 # entire reply from the server. Make sure that you have received
2626 # the entire message and then you can break the loop.
27- data = sock .recv (16 )
2827 # Log each chunk you receive. Use the print statement below to
2928 # do it. This will help in debugging problems
30- chunk = ''
31- print ('received "{0}"' .format (chunk .decode ('utf8' )), file = log_buffer )
29+ done = False
30+ while not done :
31+ chunk = sock .recv (16 )
32+ print ('received "{0}"' .format (chunk .decode ('utf8' )), file = log_buffer )
33+ if len (chunk ) < 16 :
34+ done = True
3235 finally :
3336 # TODO: after you break out of the loop receiving echoed chunks from
3437 # the server you will want to close your client socket.
@@ -37,7 +40,7 @@ def client(msg, log_buffer=sys.stderr):
3740
3841 # TODO: when all is said and done, you should return the entire reply
3942 # you received from the server as the return value of this function.
40- print ('Received' , repr (data ))
43+ print ('Received' , repr (received_message ))
4144
4245if __name__ == '__main__' :
4346 if len (sys .argv ) != 2 :
Original file line number Diff line number Diff line change @@ -51,12 +51,14 @@ def server(log_buffer=sys.stderr):
5151 # TODO: Send the data you received back to the client, log
5252 # the fact using the print statement here. It will help in
5353 # debugging problems.
54- conn .sendall (data )
55- print ('sent "{0}"' .format (data .decode ('utf8' )))
54+
5655 # TODO: Check here to see if the message you've received is
5756 # complete. If it is, break out of this inner loop.
58- if data == data :
57+ if data :
58+ conn .sendall (data )
59+ else :
5960 break
61+ print ('sent "{0}"' .format (data .decode ('utf8' )))
6062
6163 finally :
6264 # TODO: When the inner loop exits, this 'finally' clause will
You can’t perform that action at this time.
0 commit comments