zoukankan      html  css  js  c++  java
  • Python 自带 RPC Demo

    Python 自带 RPC Demo

    Server.py:

    1. from SimpleXMLRPCServer import SimpleXMLRPCServer    
    2. def fun_add(a,b): 
    3.     totle = a + b  
    4.     return totle 
    5. if __name__ == '__main__': 
    6.     s = SimpleXMLRPCServer(('0.0.0.0', 8080))   #开启xmlrpcserver 
    7.     s.register_function(fun_add)                #注册函数fun_add 
    8.     print "server is online..." 
    9.     s.serve_forever()                           #开启循环等待 

    Client.py:

    1. from xmlrpclib import ServerProxy            #导入xmlrpclib的包 
    2. s = ServerProxy("http://172.171.5.205:8080") #定义xmlrpc客户端 
    3. print s.fun_add(2,3)        
  • 相关阅读:
    UVA 10608 Friends
    UVA 10806 Dijkstra, Dijkstra.
    HDU 3715 Go Deeper
    poj1315
    poj1383
    poj1650
    poj1265
    poj1523
    RedHat9.0虚拟机安装
    注册DirectShow filter时应该注意中文路径
  • 原文地址:https://www.cnblogs.com/fengff/p/13497422.html