#服务器端
from SimpleXMLRPCServer import SimpleXMLRPCServer
def is_even(n):
return n%2 == 0server = SimpleXMLRPCServer(("localhost", 8000))#确定URL和端口print "Listening on port 8000..."server.register_function(is_even, "is_even") #注册is_even函数server.serve_forever()#启动服务器,并使其对这个连接可用#客户端
import xmlrpclib
proxy = xmlrpclib.ServerProxy("http://localhost:8000/")print "3 is even: %s" % str(proxy.is_even(3))#客户端调用RPC函数