xupeng-mingtu commented on issue #3157:
URL: https://github.com/apache/brpc/issues/3157#issuecomment-3615015840

   > 这里有个示例,每个client channel初始化时传入不同的ip是不是就能解决了
   > 
   > ```
   > #include <brpc/channel.h>
   > #include <brpc/controller.h>
   > 
   > int main() {
   >     brpc::Channel channel1;
   >     brpc::Channel channel2;
   >     brpc::ChannelOptions options;
   >     // 方式1:直接传入多个 IP:Port(用逗号分隔)
   >     std::string ip1 = "192.168.1.10:8080";
   >     if (channel1.Init(ip1.c_str(), "rr", &options) != 0) {
   >         LOG(ERROR) << "Fail to init channel";
   >         return -1;
   >     }
   >     std::string ip2 = "10.0.0.10:8080";
   >     if (channel2.Init(ip2.c_str(), "rr", &options) != 0) {
   >         LOG(ERROR) << "Fail to init channel";
   >         return -1;
   >     }
   >     // 后续正常使用 Stub 调用
   >     YourService_Stub stub1(&channel1);
   >     YourRequest req1;
   >     YourResponse res1;
   >     brpc::Controller cntl1;
   >     stub1.YourMethod(&cntl1, &req1, &res1, nullptr);
   >     
   >     YourService_Stub stub2(&channel2);
   >     YourRequest req2;
   >     YourResponse res2;
   >     brpc::Controller cntl2;
   >     stub2.YourMethod(&cntl2, &req2, &res2, nullptr);
   >     return 0;
   > }
   > ```
   
   channel这里指定的ip地址,是指定rpc 
server的服务地址吧,我想要的是,在client机器有多个ip(网卡)的情况下控制channel发送rpc时候使用的本地ip地址


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to