summaryrefslogtreecommitdiffstats
path: root/lab_control/connection/tcp_connection.py
diff options
context:
space:
mode:
Diffstat (limited to 'lab_control/connection/tcp_connection.py')
-rw-r--r--lab_control/connection/tcp_connection.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/lab_control/connection/tcp_connection.py b/lab_control/connection/tcp_connection.py
new file mode 100644
index 0000000..6af710c
--- /dev/null
+++ b/lab_control/connection/tcp_connection.py
@@ -0,0 +1,22 @@
+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