Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.