import socket HOST = "192.168.0.155" PORT = 8092 s = socket.socket() s.bind((HOST,PORT)) print("Listening for upcoming connection") s.listen() conn, addr = s.accept() print(f"Received connection from {addr}") f = open('encrypt.key', 'wb') while True: print("Receiving...") data = conn.recv(1024) if data == b"DONE": break f.write(data) f.close() s.shutdown(2) s.close()