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


Python interfaces.IReactorMulticast方法代码示例

本文整理汇总了Python中twisted.internet.interfaces.IReactorMulticast方法的典型用法代码示例。如果您正苦于以下问题:Python interfaces.IReactorMulticast方法的具体用法?Python interfaces.IReactorMulticast怎么用?Python interfaces.IReactorMulticast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.interfaces的用法示例。


在下文中一共展示了interfaces.IReactorMulticast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _join_multicast_groups

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorMulticast [as 别名]
def _join_multicast_groups(self):
        try:
            # Need to ensure that the passed-in reactor is, in fact, a "real"
            # reactor, and not None, or a mock reactor used in tests.
            verifyObject(IReactorMulticast, self.reactor)
        except DoesNotImplement:
            return
        if self.listen_port is None:
            self.listen_port = self.reactor.listenMulticast(
                self.port, self, interface=self.interface, listenMultiple=True
            )
        sock = self.transport.getHandle()
        if self.loopback:
            # This is only necessary for testing.
            self.transport.setLoopbackMode(self.loopback)
            set_ipv6_multicast_loopback(sock, self.loopback)
            self.transport.joinGroup(
                BEACON_IPV4_MULTICAST, interface="127.0.0.1"
            )
            # Loopback interface always has ifindex == 1.
            join_ipv6_beacon_group(sock, 1)
        for _, ifdata in self.interfaces.items():
            # Always try to join the IPv6 group on each interface.
            join_ipv6_beacon_group(sock, ifdata["index"])
            # Merely joining the group with the default parameters is not
            # enough, since we want to join the group on *all* interfaces.
            # So we need to join each group using an assigned IPv4 address
            # on each Ethernet interface.
            for ip in enumerate_ipv4_addresses(ifdata):
                self.transport.joinGroup(BEACON_IPV4_MULTICAST, interface=ip)
                # Use the first IP address on each interface. Since the
                # underlying interface is the same, joining using a
                # secondary IP address on the same interface will produce
                # an "Address already in use" error.
                break 
开发者ID:maas,项目名称:maas,代码行数:37,代码来源:services.py


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