2024-04-17 01:01:17 +08:00
|
|
|
import json
|
|
|
|
import multiprocessing
|
|
|
|
from multiprocessing.connection import Listener
|
|
|
|
import threading
|
2024-04-16 00:45:21 +08:00
|
|
|
|
|
|
|
|
2024-04-17 01:01:17 +08:00
|
|
|
class ProcessServer:
|
2024-04-16 00:45:21 +08:00
|
|
|
def __init__(self):
|
2024-04-17 01:01:17 +08:00
|
|
|
self.Process_port = 12321
|
|
|
|
self.Process_server = 'localhost'
|
|
|
|
self.Process_server_listener = Listener((self.Process_server, self.Process_port))
|
|
|
|
self.Process_client_link_dick = {}
|
|
|
|
Process_client_link_Thread = threading.Thread(target=self.Process_client_link)
|
|
|
|
Process_client_link_Thread.start()
|
|
|
|
|
|
|
|
def Process_client_link(self):
|
|
|
|
while True:
|
|
|
|
client_connect = self.Process_server_listener.accept()
|
|
|
|
print(type(client_connect))
|
|
|
|
|
|
|
|
client_process_recv = threading.Thread(target=self.Process_client_recv, args=(client_connect,))
|
|
|
|
client_process_recv.start()
|
|
|
|
|
|
|
|
def Process_client_recv(self, client_process_recv):
|
|
|
|
while True:
|
|
|
|
data_json = client_process_recv.recv()
|
|
|
|
data = json.loads(data_json)
|
|
|
|
print(data)
|
|
|
|
|
|
|
|
def Process_client_send(self, target, function, content):
|
|
|
|
connect = self.Process_client_link_dick[target]
|
|
|
|
data = {"target": target, "function": function, "content": content}
|
|
|
|
data_json = json.dumps(data)
|
|
|
|
connect.send(data_json)
|
|
|
|
|
|
|
|
def Process_client_pick(self):
|
|
|
|
pass
|