1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#!/usr/bin/env python3
import zmq
from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
from tinyrpc.transports.zmq import ZmqClientTransport
from tinyrpc import RPCClient
ctx = zmq.Context()
rpc_client = RPCClient(
JSONRPCProtocol(),
ZmqClientTransport.create(ctx, 'tcp://127.0.0.1:5001')
)
remote_server = rpc_client.get_proxy()
# call a method called 'reverse_string' with a single string argument
result = remote_server.reverse_string('Hello, World!')
print("Server answered:", result)
|