本文整理汇总了C++中ACE_INET_Addr::next方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_INET_Addr::next方法的具体用法?C++ ACE_INET_Addr::next怎么用?C++ ACE_INET_Addr::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_INET_Addr
的用法示例。
在下文中一共展示了ACE_INET_Addr::next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: me
void
ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs,
size_t size) const
{
if (size == 0)
return;
// Copy primary address(es) to the first slot(s) of the user-supplied array
ACE_INET_Addr me (*this);
size_t i = 0;
for (i = 0; i < size; ++i)
{
sockaddr_in6 *in6 = reinterpret_cast<sockaddr_in6*> (me.get_addr ());
if (in6->sin6_family == AF_INET6)
{
addrs[i] = *in6;
++i;
}
if (!me.next ())
break;
}
// Copy secondary addresses to remaining slots of the user-supplied
// array. Secondary address [i] is copied to slot [i+1]
for (size_t j = 0; j < this->secondaries_.size (); ++j)
{
ACE_INET_Addr copy (this->secondaries_[j]);
for (; i < size; ++i)
{
sockaddr_in6 *in6 =
reinterpret_cast<sockaddr_in6*> (copy.get_addr ());
if (in6->sin6_family == AF_INET6)
{
addrs[i] = *in6;
++i;
}
if (!copy.next ())
break;
}
}
}
示例2: test_multiple
static bool test_multiple (void)
{
bool success = true;
// Check the behavior when there are multiple addresses assigned to a name.
// The NTP pool should always return multiples, though always different.
ACE_INET_Addr ntp;
if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1)
{
// This is just a warning to prevent fails on lookups on hosts with no
// DNS service. The real value of this test is to accurately get
// multiples from the result.
ACE_ERROR ((LM_WARNING, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org")));
return true;
}
size_t count = 0;
ACE_TCHAR addr_string[256];
do
{
++count; // If lookup succeeded, there's at least one
ntp.addr_to_string (addr_string, sizeof (addr_string));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string));
}
while (ntp.next ());
success = count > 1;
#if defined (ACE_HAS_IPV6)
ACE_INET_Addr ntp6;
if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org")));
return false;
}
count = 0;
do
{
++count; // If lookup succeeded, there's at least one
ntp6.addr_to_string (addr_string, sizeof (addr_string));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string));
}
while (ntp6.next ());
if (count <= 1)
success = false;
#endif /* ACE_HAS_IPV6 */
return success;
}