blob: 0c0fcfc3be6a878b29195f8dfb34256a943e5cd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/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]:
cmd = argv[2].encode("ascii")
else:
cmd = b"hello"
# 1 char in Python is 2 bytes instead of 1 byte in C
cmd += b"\tserver\tworld\thello"
cmd_len = acccre_size(getsizeof(cmd))
sun.send(cmd_len)
sun.send(cmd)
print(str(sun.recv(5)))
sun.close
|