python-zatobox 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-zatobox
3
+ Version: 0.1.0
4
+ Summary:
5
+ Author: woutervanoverberghe
6
+ Author-email: wouter.vanoverberghe@vanutech.be
7
+ Requires-Python: >=3.11,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Description-Content-Type: text/markdown
13
+
14
+
File without changes
@@ -0,0 +1,14 @@
1
+ [tool.poetry]
2
+ name = "python-zatobox"
3
+ version = "0.1.0"
4
+ description = ""
5
+ authors = ["woutervanoverberghe <wouter.vanoverberghe@vanutech.be>"]
6
+ readme = "README.md"
7
+
8
+ [tool.poetry.dependencies]
9
+ python = "^3.11"
10
+
11
+
12
+ [build-system]
13
+ requires = ["poetry-core"]
14
+ build-backend = "poetry.core.masonry.api"
File without changes
@@ -0,0 +1,39 @@
1
+
2
+
3
+ import socket
4
+
5
+ class TCPClient:
6
+ def __init__(self, ip_address, port=3333) -> None:
7
+ self.ip_address = ip_address
8
+ self.port = port
9
+ self.tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
10
+
11
+ def connect(self):
12
+ try:
13
+ self.tcp_socket.connect((self.ip_address, self.port))
14
+ print(f"Connected to {self.ip_address} on port {self.port}")
15
+ except Exception as e:
16
+ print(f"Failed to connect: {e}")
17
+
18
+ def listen(self):
19
+ try:
20
+ while True:
21
+ data = self.tcp_socket.recv(1024)
22
+ if not data:
23
+ break
24
+ print(f"Received data: {data.decode('utf-8')}")
25
+ except Exception as e:
26
+ print(f"Error receiving data: {e}")
27
+ finally:
28
+ self.close()
29
+
30
+ def close(self):
31
+ print("Closing socket")
32
+ self.tcp_socket.close()
33
+
34
+ # Example usage
35
+ if __name__ == "__main__":
36
+ ip_address = "127.0.0.1" # Replace with the actual IP address of the device
37
+ client = TCPClient(ip_address)
38
+ client.connect()
39
+ client.listen()