mirror of
https://github.com/besterprotocol/besterd
synced 2023-12-13 21:00:32 +01:00
28 lines
No EOL
768 B
Python
Executable file
28 lines
No EOL
768 B
Python
Executable file
#!/bin/python3
|
|
|
|
import socket
|
|
import json
|
|
|
|
def runTest():
|
|
d=socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
d.bind("../aSock")
|
|
d.listen()
|
|
while True:
|
|
print("Waiting for connection to (this) handler...")
|
|
s = d.accept()[0]
|
|
|
|
size=int.from_bytes(s.recv(4), "little")
|
|
receivedBys = json.loads(s.recv(size).decode())
|
|
print(receivedBys)
|
|
bys = json.dumps({
|
|
"header" : {
|
|
"status" : "0",
|
|
"command" : {"type" : "sendClients", "data": ["tbk", "skippy"]}
|
|
}, "data" : receivedBys })
|
|
print(s.send(len(bys).to_bytes(4, "little")))
|
|
print(s.send(bys.encode()))
|
|
print("Connection to (this) handler finished")
|
|
|
|
while True: pass
|
|
|
|
runTest() |