"""
@author: JHC000abc@gmail.com
@file: server.py
@time: 2023/7/29 21:00
@desc: 服务端代码
"""
from xmlrpc.server import SimpleXMLRPCServer
class Test():
def test(self):
print("rpc-test")
return "rpc-test"
def name(self):
print("rpc-name")
return "rpc-name"
if __name__ == '__main__':
server = SimpleXMLRPCServer(("服务器ip",服务器端口),allow_none=True)
server.register_instance(Test(),allow_dotted_names=True)
server.serve_forever()
"""
@author: JHC000abc@gmail.com
@file: client.py
@time: 2023/7/29 20:54
@desc: 客户端
"""
from xmlrpc.client import ServerProxy
if __name__ == '__main__':
client = ServerProxy("http://服务器ip:服务器端口")
print(client.test())
print(client.name())