zero ice 如何获取本地以及对端IP 地址及端口号

 1 // 在客户端显示端点连接IP及端口号信息
 2 static void show_endpoint(const Ice::ObjectPrx &proxy)
 3 {
 4     Ice::ConnectionPtr conn = proxy->ice_getConnection();
 5     if(conn)
 6     {
 7         cout << conn->type() << endl;
 8         cout << conn->toString() << endl;
 9         Ice::ConnectionInfoPtr conn_info = conn->getInfo();
10         ::Ice::EndpointPtr ep_ptr = conn->getEndpoint();
11         cout << ep_ptr->toString() << endl;
12 
13         Ice::IPConnectionInfoPtr ipInfo = Ice::IPConnectionInfoPtr::dynamicCast(conn_info);
14         cout << ipInfo->localAddress << ":" << ipInfo->localPort << endl;
15         cout << ipInfo->remoteAddress << ":" << ipInfo->remotePort << endl;
16     }
17     else
18     {
19         cout << "collocated" << endl;
20     }
21 }
原文地址:https://www.cnblogs.com/suyunhong/p/4952008.html