Created
January 23, 2020 10:24
-
-
Save BMU-Verlag/639f9648065a19c7a143b008d3e9801f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def receive(): | |
try: | |
message_size = client_socket.recv(LENGTH_HEADER_SIZE) | |
if message_size: | |
message_size = int(message_size.decode('utf-8').strip()) | |
sender = client_socket.recv(USER_HEADER_SIZE).decode('utf-8').strip() | |
message = client_socket.recv(message_size).decode('utf-8') | |
print(f'{sender} > {message}') | |
except IOError as e: | |
if e.errno != errno.EAGAIN and e.errno != errno.EWOULDBLOCK: | |
print('Encountered error while reading', e) | |
client_socket.close() | |
sys.exit() | |
except Exception as e: | |
client_socket.close() | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment