Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/client.py
diff options
context:
space:
mode:
authorIvan Davydov <lotigara@lotigara.ru>2025-06-17 14:32:27 +0300
committerIvan Davydov <lotigara@lotigara.ru>2025-06-17 14:32:27 +0300
commit9d945cd7e55c7d4f432dbe8ea758178fadd44b04 (patch)
tree1a793e9fe1c2defe25ab5d687f20798ecbf34bb0 /client.py
Initial commit
Diffstat (limited to 'client.py')
-rwxr-xr-xclient.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/client.py b/client.py
new file mode 100755
index 0000000..26548c2
--- /dev/null
+++ b/client.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+from ctypes import c_uint16 as acccre_size
+from socket import *
+from sys import *
+
+sun = socket(AF_UNIX)
+if len(argv) >= 2 and argv[1]:
+ sun_path = argv[1]
+else:
+ sun_path = "./acccre.sock"
+
+try:
+ sun.connect(sun_path)
+except FileNotFoundError as e:
+ exit(e)
+
+if len(argv) >= 3 and argv[2]:
+ msg = argv[2].encode("ascii")
+else:
+ msg = b"hello, world!"
+
+# 1 char in Python is 2 bytes instead of 1 byte in C
+#msg_len = acccre_size(getsizeof(msg))
+msg_len = acccre_size(2)
+sun.send(msg_len)
+sun.send(msg)
+sun.close