本文整理汇总了C++中NetworkInterface::index方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkInterface::index方法的具体用法?C++ NetworkInterface::index怎么用?C++ NetworkInterface::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkInterface
的用法示例。
在下文中一共展示了NetworkInterface::index方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testForIndex
void NetworkInterfaceTest::testForIndex()
{
NetworkInterface::Map map = NetworkInterface::map();
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
{
NetworkInterface ifc = NetworkInterface::forIndex(it->second.index());
assert (ifc.index() == it->second.index());
}
}
示例2: setInterface
void MulticastSocket::setInterface(const NetworkInterface& interface)
{
if (!interface.supportsIPv6())
{
impl()->setOption(IPPROTO_IP, IP_MULTICAST_IF, interface.address());
}
else
{
#if defined(POCO_HAVE_IPv6)
impl()->setOption(IPPROTO_IPV6, IPV6_MULTICAST_IF, interface.index());
#endif
}
}
示例3: setInterface
void MulticastSocket::setInterface(const NetworkInterface& interfc)
{
if (address().family() == IPAddress::IPv4)
{
impl()->setOption(IPPROTO_IP, IP_MULTICAST_IF, interfc.firstAddress(IPAddress::IPv4));
}
#if defined(POCO_HAVE_IPv6)
else if (address().family() == IPAddress::IPv6)
{
impl()->setOption(IPPROTO_IPV6, IPV6_MULTICAST_IF, interfc.index());
}
#endif
else
throw UnsupportedFamilyException("Unknown or unsupported socket family.");
}
示例4: leaveGroup
void MulticastSocket::leaveGroup(const IPAddress& groupAddress, const NetworkInterface& interfc)
{
if (groupAddress.af() == AF_INET)
{
struct ip_mreq mr;
std::memcpy(&mr.imr_multiaddr, groupAddress.addr(), groupAddress.length());
std::memcpy(&mr.imr_interface, interfc.firstAddress(IPAddress::IPv4).addr(), interfc.firstAddress(IPAddress::IPv4).length());
impl()->setRawOption(IPPROTO_IP, IP_DROP_MEMBERSHIP, &mr, sizeof(mr));
}
else
{
#if defined(POCO_HAVE_IPv6)
struct ipv6_mreq mr;
std::memcpy(&mr.ipv6mr_multiaddr, groupAddress.addr(), groupAddress.length());
mr.ipv6mr_interface = interfc.index();
impl()->setRawOption(IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mr, sizeof(mr));
#endif
}
}