import socket class TCPConnection: def __init__(self, ip: str, port: int): self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._socket.connect((address, port)) def configure(self, config: dict) -> None: self._socket.settimeout(parameters["timeout"]) def send(self, request, responseExpected=True): self._socket.sendall(request.encode()) if responseExpected: try: response = self._socket.recv(4096).decode() except TimeoutError: response = None return response def checkConfiguration(self) -> None: pass