Beispiel #1
0
def run():
    conn = grpc.insecure_channel(_HOST + ':' + _PORT)  # 服务器信息
    client = data_pb2_grpc.FormatDataStub(channel=conn)  # 客户端建立连接
    for i in range(0, 2):
        respnse = client.DoFormat(
            data_pb2.Data(text='hello,world!'))  # 序列化数据传递过去
        print("received: " + respnse.text)
Beispiel #2
0
def run():
    conn = grpc.insecure_channel(target=(_HOST + ':' + _PORT))  # 创建一个连接对象
    print(conn)
    client = data_pb2_grpc.FormatDataStub(
        channel=conn)  # 客户端使用Stub类发送请求,参数为频道,为了绑定链接
    print(client)
    response = client.DoFormat(
        data_pb2.actionrequest(text='hello, python!'))  # 返回的结果就是proto中定义的类
    print("received: " + response.text)
def run():
    conn = grpc.insecure_channel(_HOST + ':' + _PORT)
    client = data_pb2_grpc.FormatDataStub(channel=conn)
    response = client.DoFormat(data_pb2.Data(text='hello,world!'))
    print("received: " + response.text)