本文整理汇总了C++中ice::ObjectPrxPtr::ice_collocationOptimized方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectPrxPtr::ice_collocationOptimized方法的具体用法?C++ ObjectPrxPtr::ice_collocationOptimized怎么用?C++ ObjectPrxPtr::ice_collocationOptimized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ObjectPrxPtr
的用法示例。
在下文中一共展示了ObjectPrxPtr::ice_collocationOptimized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTestEndpoint
//.........这里部分代码省略.........
#if defined(_WIN32) && !defined(ICE_OS_WINRT)
OSVERSIONINFO ver;
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
# if defined(_MSC_VER) && _MSC_VER >= 1800
# pragma warning (disable : 4996)
# endif
GetVersionEx(&ver);
# if defined(_MSC_VER) && _MSC_VER >= 1800
# pragma warning (default : 4996)
# endif
const bool dualStack = ver.dwMajorVersion >= 6; // Windows XP IPv6 doesn't support dual-stack
#else
const bool dualStack = true;
#endif
bool ipv6NotSupported = false;
for(vector<Ice::PropertiesPtr>::const_iterator p = serverProps.begin(); p != serverProps.end(); ++p)
{
Ice::InitializationData serverInitData;
serverInitData.properties = *p;
Ice::CommunicatorPtr serverCommunicator = Ice::initialize(serverInitData);
Ice::ObjectAdapterPtr oa;
try
{
oa = serverCommunicator->createObjectAdapter("Adapter");
oa->activate();
}
catch(const Ice::DNSException&)
{
serverCommunicator->destroy();
continue; // IP version not supported.
}
catch(const Ice::SocketException&)
{
if(*p == ipv6)
{
ipv6NotSupported = true;
}
serverCommunicator->destroy();
continue; // IP version not supported.
}
// Ensure the published endpoints are actually valid. On
// Fedora, binding to "localhost" with IPv6 only works but
// resolving localhost don't return the IPv6 adress.
Ice::ObjectPrxPtr prx = oa->createProxy(serverCommunicator->stringToIdentity("dummy"));
try
{
prx->ice_collocationOptimized(false)->ice_ping();
}
catch(const Ice::LocalException&)
{
serverCommunicator->destroy();
continue; // IP version not supported.
}
string strPrx = prx->ice_toString();
for(vector<Ice::PropertiesPtr>::const_iterator q = clientProps.begin(); q != clientProps.end(); ++q)
{
Ice::InitializationData clientInitData;
clientInitData.properties = *q;
Ice::CommunicatorHolder clientCommunicator = Ice::initialize(clientInitData);
Ice::ObjectPrxPtr prx = clientCommunicator->stringToProxy(strPrx);
try
{
prx->ice_ping();
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// Expected, no object registered.
}
catch(const Ice::DNSException&)
{
// Expected if no IPv4 or IPv6 address is
// associated to localhost or if trying to connect
// to an any endpoint with the wrong IP version,
// e.g.: resolving an IPv4 address when only IPv6
// is enabled fails with a DNS exception.
}
catch(const Ice::SocketException&)
{
test((*p == ipv4 && *q == ipv6) || (*p == ipv6 && *q == ipv4) ||
(*p == bothPreferIPv4 && *q == ipv6) || (*p == bothPreferIPv6 && *q == ipv4) ||
(*p == bothPreferIPv6 && *q == ipv6 && ipv6NotSupported) ||
(*p == anyipv4 && *q == ipv6) || (*p == anyipv6 && *q == ipv4) ||
(*p == anyboth && *q == ipv4 && !dualStack) ||
(*p == localipv4 && *q == ipv6) || (*p == localipv6 && *q == ipv4) ||
(*p == ipv6 && *q == bothPreferIPv4) || (*p == ipv6 && *q == bothPreferIPv6) ||
(*p == bothPreferIPv6 && *q == ipv6));
}
}
serverCommunicator->destroy();
}
cout << "ok" << endl;
}
com->shutdown();
}