Skip to content

Instantly share code, notes, and snippets.

@ahmedfgad
Created June 27, 2020 00:25
Show Gist options
  • Save ahmedfgad/0c0b01fc3bc3b1cdad937c6b6a036137 to your computer and use it in GitHub Desktop.
Save ahmedfgad/0c0b01fc3bc3b1cdad937c6b6a036137 to your computer and use it in GitHub Desktop.
def run(self):
while True:
self.recv_start_time = time.time()
time_struct = time.gmtime()
date_time = "Waiting to Receive Data Starting from {day}/{month}/{year} {hour}:{minute}:{second} GMT".format(year=time_struct.tm_year, month=time_struct.tm_mon, day=time_struct.tm_mday, hour=time_struct.tm_hour, minute=time_struct.tm_min, second=time_struct.tm_sec)
print(date_time)
received_data, status = self.recv()
if status == 0:
self.connection.close()
print("Connection Closed with {client_info} either due to inactivity for {recv_timeout} seconds or due to an error.".format(client_info=self.client_info, recv_timeout=self.recv_timeout), end="\n\n")
break
msg = "Reply from the server."
msg = pickle.dumps(msg)
connection.sendall(msg)
print("Server sent a message to the client.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment