当前位置: 首页>>代码示例>>C++>>正文


C++ ACE_INET_Addr::next方法代码示例

本文整理汇总了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;
        }
    }
}
开发者ID:GlassFace,项目名称:sunwell,代码行数:40,代码来源:Multihomed_INET_Addr.cpp

示例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;
}
开发者ID:INMarkus,项目名称:ATCD,代码行数:48,代码来源:INET_Addr_Test.cpp


注:本文中的ACE_INET_Addr::next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。