from typing import Dict, Any import socket import msgpack SERVER_ADDRESS = ('172.16.0.249', 8888) def send_request(data:Dict[str, Any]): client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect(SERVER_ADDRESS) try: message:bytes = msgpack.packb(data) client_socket.sendall(message) rx = client_socket.recv(1024) if data: print(f"Received message: {rx.decode('utf-8').strip()}") else: print("Connection closed") return except ConnectionResetError: print("Connection reset") finally: client_socket.close() print("Connection closed")