def msgpack_client(): # メッセージバックによるRPC実装のクライアント from msgpackrpc import Client, Address client = Client(Address("localhost", 6789)) # サーバーに接続 num = 8 result = client.call('double', num) # double をリモート呼び出し print("Double %s is %s" % (num, result))
def msgpack_server(): # メッセージバックによるRPC実装のサーバー from msgpackrpc import Server, Address class Services(): def double(self, num): return num * 2 server = Server(Services()) # ServicesクラスのメソッドをRPCサービスとして提供 server.listen(Address("localhost", 6789)) # localhost:6789でリスン server.start()
from msgpackrpc import Server, Address class Services(): def double(self, num): return num * 2 server = Server(Services()) server.listen(Address("localhost", 6789)) server.start()
from msgpackrpc import Server, Address class Services(): def double(self, num): return num * 2 server = Server(Services()) server.listen(Address('localhost', 6789)) server.start()
# -*- coding: utf-8 -*- """ msgpack_client.py Created on Sat Apr 20 11:19:17 2019 @author: madhu start /b python msgpack_server.py python xmlrpc_client.py """ from msgpackrpc import Client, Address host_name = 'localhost' port_num = 6789 client = Client(Address(host_name, port_num)) num = 8 result = client.call('double', num) print("Double %s is %s" % (num, result))
from msgpackrpc import Client, Address client = Client(Address('localhost', 6789)) num = 8 result = client.call('double', num) print("double %s is %s" % (num, result))
# -*- coding: utf-8 -*- """ msgpack_server.py Created on Sat Apr 20 11:19:17 2019 @author: madhu start /b python msgpack_server.py python xmlrpc_client.py """ from msgpackrpc import Server, Address class Services(): def double(self, num): return num * 2 host_name = 'localhost' port_num = 6789 server = Server(Services()) server.listen(Address(host_name, port_num)) server.start()
#!/usr/bin/env python3 #-*- coding:utf-8 -*- # Created by nobuskate on 2018/01/19. # import from msgpackrpc import Client, Address client = Client(Address("localhost", 6789)) num = 8 result = client.call('double', num) print("Double %s is %s" % (num, result))
# RPC Server from msgpackrpc import Server, Address class Services(): def double(self, num): return num * 2 server = Server(Services()) server.listen(Address("localhost", 6789)) server.start() # RPC Client from msgpackrpc import Client, Address client = Client(Address("localhost", 6789)) num = 8 result = client.call('double', num) print("Double %s is %s" % (num, result))