Created
January 23, 2020 13:53
-
-
Save BMU-Verlag/6141a9ea25d5f06525fb56b24657a10f 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_message (f'\n{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