简单的xpcrpc服务器

服务器程序

from xmlrpc.server import SimpleXMLRPCServer
server=SimpleXMLRPCServer(('localhost',12345))
def test():
    print('测试')
    return 1
server.register_function(test)
server.serve_forever()

客户端程序

import xmlrpc.client
proxy=xmlrpc.client.ServerProxy('http://localhost:12345')
print(proxy.test())

搭建xmlrpc服务器利用python的xmlrpc模块。
xmlrpc即远程程序调用,是基于http的,http传递的数据类型是xml,用来标识调用的函数,参数等,利用抓包工具抓http包可以看到对应的xml数据。

发布了62 篇原创文章 · 获赞 83 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_41033366/article/details/104250266