2020-04-30 15:55:40 +02:00
|
|
|
import socket
|
|
|
|
import json
|
|
|
|
|
|
|
|
def runTest():
|
|
|
|
d=socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
2020-04-30 18:03:50 +02:00
|
|
|
d.bind("../aSock")
|
2020-04-30 15:55:40 +02:00
|
|
|
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)
|
|
|
|
|
2020-04-30 18:03:50 +02:00
|
|
|
# bys = json.dumps({
|
|
|
|
# "header" : {
|
|
|
|
# "status" : "0",
|
|
|
|
# "command" : {"type" : "sendHandler", "data": "type1"}
|
|
|
|
# }, "data" : receivedBys["bruhMsg"] })
|
|
|
|
# print(s.send(len(bys).to_bytes(4, "little")))
|
|
|
|
# print(s.send(bys.encode()))
|
2020-04-30 15:55:40 +02:00
|
|
|
|
|
|
|
bys = json.dumps({
|
|
|
|
"header" : {
|
|
|
|
"status" : "0",
|
|
|
|
"command" : {"type" : "sendServers", "data": ["10.0.0.4:2223"]}
|
2020-04-30 18:03:50 +02:00
|
|
|
}, "data" : receivedBys })
|
|
|
|
print(s.send(len(bys).to_bytes(4, "little")))
|
|
|
|
print(s.send(bys.encode()))
|
2020-04-30 15:55:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
print("Connection to (this) handler finished")
|
|
|
|
|
|
|
|
while True: pass
|
|
|
|
|
|
|
|
runTest()
|