• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python reactor.listenMulticast函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.internet.reactor.listenMulticast函数的典型用法代码示例。如果您正苦于以下问题:Python listenMulticast函数的具体用法?Python listenMulticast怎么用?Python listenMulticast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: setUp

 def setUp(self):
     self.server = Server()
     self.client = Client()
     # multicast won't work if we listen over loopback, apparently
     self.port1 = reactor.listenMulticast(0, self.server)
     self.port2 = reactor.listenMulticast(0, self.client)
     self.client.transport.connect("127.0.0.1", self.server.transport.getHost().port)
开发者ID:steder,项目名称:twisted,代码行数:7,代码来源:test_udp.py


示例2: main

def main():
    p = argparse.ArgumentParser(description='Paradrop daemon running on client')
    p.add_argument('--mode', '-m', help='Set the mode to one of [production, local, unittest]',
                   action='store', type=str, default='production')
    p.add_argument('--portal', '-p', help='Set the folder of files for local portal',
                   action='store', type=str)
    p.add_argument('--no-exec', help='Skip execution of configuration commands',
                   action='store_false', dest='execute')

    args = p.parse_args()
    # print args

    settings.loadSettings(args.mode, [])

    update_manager = UpdateManager(reactor)
    update_fetcher = UpdateFetcher(update_manager)
    WampSession.set_update_fetcher(update_fetcher)
    ProcessMonitor.allowedActions = set()

    # Start the configuration service as a thread
    confd.main.run_thread(execute=args.execute)

    airshark_manager = AirsharkManager()

    # Globally assign the nexus object so anyone else can access it.
    nexus.core = Nexus(update_fetcher, update_manager)
    http_server = HttpServer(update_manager, update_fetcher, airshark_manager, args.portal)
    setup_http_server(http_server, '0.0.0.0', settings.PORTAL_SERVER_PORT)
    reactor.listenMulticast(1900, SsdpResponder(), listenMultiple=True)

    reactor.run()
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:31,代码来源:main.py


示例3: main

def main():
    log.startLogging(sys.stdout)
    parser = argparse.ArgumentParser(description="Exchange files!")
    args = parser.parse_args()
    
    # Initialize peer discovery using UDP multicast
    multiCastPort = 8006
    teiler = TeilerState()
    teiler.multiCastPort = multiCastPort
    reactor.listenMulticast(multiCastPort,
                            PeerDiscovery(teiler),
                            listenMultiple=True)
    log.msg("Initiating Peer Discovery")
    
    app = TeilerWindow(teiler)
    # Initialize file transfer service
    fileReceiver = FileReceiverFactory(teiler, app)
    reactor.listenTCP(teiler.tcpPort, fileReceiver)
    log.msg("Starting file listener on ", teiler.tcpPort)
    
    # qt4reactor requires runReturn() in order to work
    reactor.runReturn()
    
    # filetransfer.sendFile("/home/armin/tempzip.zip",port=teiler.tcpPort,address=teiler.address)
    # Create an instance of the application window and run it
    
    app.run()
开发者ID:arminhammer,项目名称:cteiler,代码行数:27,代码来源:teiler.py


示例4: setUp

 def setUp(self):
     self.receiver = dispatch.Receiver()
     self.serverPort = reactor.listenMulticast(17778, async.MulticastDatagramServerProtocol(self.receiver, "224.0.0.1"), listenMultiple=True)
     self.receiver2 = dispatch.Receiver()
     self.serverPort2 = reactor.listenMulticast(17778, async.MulticastDatagramServerProtocol(self.receiver2, "224.0.0.1"), listenMultiple=True)
     self.client = async.DatagramClientProtocol()
     self.clientPort = reactor.listenUDP(0, self.client)
开发者ID:aalex,项目名称:txosc,代码行数:7,代码来源:test_async.py


示例5: start

    def start(self):
        dserver = defer.Deferred()
        dclient = defer.Deferred()
        try:
            self.ssdp = reactor.listenMulticast(SSDP_PORT,
                                                ServerBase(self._node_id,
                                                           self._control_uri,
                                                           self.iface_send_list,
                                                           d=dserver
                                                          ),
                                                listenMultiple=True)
            self.ssdp.setTTL(5)
            for iface_ in self.iface_send_list:
                d = self.ssdp.joinGroup(SSDP_ADDR, interface=iface_)
                d.addErrback(lambda x: _log.error("Failed to join multicast group %s:%s, %s", iface_, SSDP_PORT, x))
                d.addCallback(lambda x: _log.debug("Joined multicast group %s:%s, %s", iface_, SSDP_PORT, x))
        except:
            _log.exception("Multicast listen join failed!!")
            # Dont start server some one is alerady running locally

        # TODO: Do we need this ?
        self.port = reactor.listenMulticast(0, ClientBase(dclient=dclient), interface=self.iface)
        _log.debug("SSDP Host: %s" % repr(self.port.getHost()))

        # Set ignore port and ips
        if self.ssdp and self.ignore_self:
            self.ssdp.protocol.set_ignore_list([(x, self.port.getHost().port) for x in self.iface_send_list])

        return dserver, dclient
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:29,代码来源:service_discovery_ssdp.py


示例6: build

 def build(self):
     # conexao UDP com os tratores
     self.conexao = Echo (self)
     reactor.listenMulticast (10000, self.conexao, listenMultiple = True)
     # escreve os logs a cada 10 segundos, pra nao perder
     Clock.schedule_interval (self.conexao.writeLogs, 10)
     return Builder.load_string(kv)
开发者ID:gmocellin,项目名称:Topcommpany,代码行数:7,代码来源:server.py


示例7: startPD

def startPD():
    p=Peer(uid=uuid1().hex, name='anon',addr='127.0.0.1')
    p_l=PeerContainer(refAdd, refDel)
    i=Inducter(('224.0.2.38',8999))
    reactor.listenMulticast(8999,i)
    h=MessageHandler(p, i.broadcast, p_l)
    i.addHandler(h.handle)
开发者ID:scottydelta,项目名称:FiSH,代码行数:7,代码来源:prompt.py


示例8: __init__

    def __init__(self, address="224.0.0.251", port=5353):
        self.address = address
        self.port = port

        self.proto = MulticastDNSProtocol(self)

        reactor.listenMulticast(port, self.proto, listenMultiple=True)
开发者ID:cfinucane,项目名称:mdns-hog,代码行数:7,代码来源:mdns-hog.py


示例9: main

def main():
    init_parser = argparse.ArgumentParser(description="Code or binary over LAN execution", add_help=False)
    init_parser.add_argument('--port', action="store", type=int, default=8005, help="Network port to use, default 8005")
    group_client_server = init_parser.add_mutually_exclusive_group(required=True)
    group_client_server.add_argument('--client', action="store_false", help="Start client with some query")
    group_client_server.add_argument('--server', action="store_true", help="Start as server, waiting for connections")
    init_parser.add_argument('--version', action='version', version='%(prog)s 0.1')
    init_args, other_args = init_parser.parse_known_args()
    if init_args.server is False:
        parser = argparse.ArgumentParser(parents=[init_parser])
        parser.add_argument('--localfile', action="store", type=str, help="Local file to load on servers")
        parser.add_argument('--tries', action="store", type=int, default=1, help="How many times to exec")
        group_arch_bin_script = parser.add_mutually_exclusive_group()
        group_arch_bin_script.add_argument('--archive', action="store_true", help="If localfile is archive")
        group_arch_bin_script.add_argument('--executable', action="store_false",
                                           help="If localfile is binary or script")
        parser.add_argument('--execstr', action="store", type=str, required=True,
                            help="Your regular shell exec: filename and args, to be launched on remote machine")
        args, other_args = parser.parse_known_args()
    elif init_args.server is True:
        parser = argparse.ArgumentParser(parents=[init_parser])
        parser.add_argument('--whitelist', action="store", type=str, help="File with allowed IP's, in A.B.C.D format")
        args, other_args = parser.parse_known_args()

    if init_args.server:
        reactor.listenMulticast(init_args.port, MulticastDevopsServerProtocol(init_args.port, args.whitelist),
                                listenMultiple=True)
    else:
        reactor.listenMulticast(init_args.port, MulticastDevopsClientProtocol(init_args.port, args),
                                listenMultiple=True)
    return reactor.run()
开发者ID:azanegin,项目名称:castchat,代码行数:31,代码来源:devops.py


示例10: setup

def setup(clientPort):
    global peerlist
    peerlist = PeerList()
    _log.info('client_ip = %s', socket.gethostbyname(socket.gethostname()))
    br = Broadcaster(peerlist, clientPort)
    reactor.listenMulticast(9999, br, listenMultiple=True) #@UndefinedVariable
    l = task.LoopingCall(br.sendDatagram)
    l.start(3.0)
开发者ID:himikof,项目名称:net-lab,代码行数:8,代码来源:broadcaster.py


示例11: StartSSDPServer

def StartSSDPServer():
  """Start an SSDP server.

  Used for debugging/testing just an SSDP server.
  """
  logging.info('SSDPServer started')
  reactor.listenMulticast(1900, SSDPServer(), listenMultiple=True)
  reactor.run()
开发者ID:birgerro,项目名称:pc-autobackup,代码行数:8,代码来源:ssdp.py


示例12: born

 def born(self, data):
     """Method initiate TCL and UDP listeners."""
     lc = LoopingCall(get_metrics, None)
     lc.start(2)
     reactor.listenUDP(self.UDP_PORT, NotificationUDPProcessor())
     reactor.listenMulticast(self.MULTICAST_PORT,
                             MunticastNotificationProcessor(self.MULTICAST_IP), # add multicast 'born' processing
                             listenMultiple=True)
     endpoints.serverFromString(reactor, "tcp:21999").listen(EchoFactory())
开发者ID:adyachok,项目名称:distributed-systems-study,代码行数:9,代码来源:host_fsm.py


示例13: __init__

 def __init__(self, torrent):
     self.torrent = torrent
     self.id = 0
     self.swarm_size = 1
     self.peers = [None, None] # [0] left, [1] right
     self.msgcache = MsgCache()
     self.client_factory = PeerProtocol.BTClientFactory(torrent, True)
     self.lndp_finder = LNDPFinder(self)
     reactor.listenMulticast(MULTICAST_PORT, self.lndp_finder, listenMultiple=True)
开发者ID:DhruvPatel01,项目名称:dtoc,代码行数:9,代码来源:LNDP.py


示例14: send_udp_mcast

def send_udp_mcast(data, mcast_ip, mcast_port):
    """Sends UDP packet to a multicast group without waiting for a response
    :param data: (String) data value which have to be send
    :param mcast_group: (String) IP of a multicast group
    :return: None
    """
    # 0 means every port, we don't care
    reactor.listenMulticast(0, MulticastSender(data, mcast_ip, mcast_port),
                            listenMultiple=True)
开发者ID:adyachok,项目名称:distributed-systems-study,代码行数:9,代码来源:senders.py


示例15: main

def main():
    parser = ArgumentParser()
    parser.add_argument('--node_id', '-n',
                            type=long,
                            required=True)
    parser.add_argument('--verbose', '-v', action='store_true')
    args = parser.parse_args()

    reactor.listenMulticast(PORT, BFT2F_Node(args.node_id, args.verbose), listenMultiple=True)
    reactor.run()
开发者ID:akshayka,项目名称:bft2f,代码行数:10,代码来源:start_evilnode.py


示例16: run

    def run(self):
        from twisted.internet import reactor
        from twisted.python import log

        reactor.listenMulticast(8005, HolaListener(self.queue), listenMultiple=True)

        self.reactor = reactor
        reactor.callLater(1, self.__checkShutdown)
        log.defaultObserver.stop()
        reactor.run()
开发者ID:sys-git,项目名称:YATES,代码行数:10,代码来源:UDP.py


示例17: testMultiListen

 def testMultiListen(self):
     c = Server()
     p = reactor.listenMulticast(0, c, listenMultiple=True)
     self.runUntilSuccess(self.server.transport.joinGroup, "225.0.0.250")
     portno = p.getHost().port
     c2 = Server()
     p2 = reactor.listenMulticast(portno, c2, listenMultiple=True)
     self.runUntilSuccess(self.server.transport.joinGroup, "225.0.0.250")
     c.transport.write("hello world", ("225.0.0.250", portno))
     d = defer.Deferred()
     reactor.callLater(0.4, d.callback, None, c, c2, p, p2)
     return d
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:12,代码来源:test_udp.py


示例18: main

def main():
    reactor.disconnectAll()
    failover = False
    if settings.POOL_FAILOVER_ENABLE:
        failover = settings.failover_pool
        settings.failover_pool = not settings.failover_pool

    pool_host = settings.POOL_HOST
    pool_port = settings.POOL_PORT
    if failover and settings.POOL_FAILOVER_ENABLE:
        pool_host = settings.POOL_HOST_FAILOVER
        pool_port = settings.POOL_PORT_FAILOVER

    log.warning("Monero Stratum proxy version: %s" % version.VERSION)
    log.warning("Trying to connect to Stratum pool at %s:%d" % (pool_host, pool_port))
        
    # Connect to Stratum pool, main monitoring connection
    f = SocketTransportClientFactory(pool_host, pool_port,
                debug=settings.DEBUG, proxy=None,
                event_handler=client_service.ClientMiningService)

    job_registry = jobs.JobRegistry(f)
    client_service.ClientMiningService.job_registry = job_registry
    client_service.ClientMiningService.reset_timeout()
    
    f.on_connect.addCallback(on_connect)
    f.on_disconnect.addCallback(on_disconnect)
    # Cleanup properly on shutdown
    reactor.addSystemEventTrigger('before', 'shutdown', on_shutdown, f)

    # Block until proxy connect to the pool
    try:
        yield f.on_connect
    except TransportException:
        log.warning("First pool server must be online first time to start failover")
        return
    
    # Setup stratum listener
    stratum_listener.StratumProxyService._set_upstream_factory(f)
    stratum_listener.StratumProxyService._set_custom_user(settings.CUSTOM_USER, settings.CUSTOM_PASSWORD, settings.ENABLE_WORKER_ID, settings.WORKER_ID_FROM_IP)
    reactor.listenTCP(settings.STRATUM_PORT, SocketTransportFactory(debug=settings.DEBUG, event_handler=ServiceEventHandler), interface=settings.STRATUM_HOST)
    
    # Setup multicast responder
    reactor.listenMulticast(3333, multicast_responder.MulticastResponder((pool_host, pool_port), settings.STRATUM_PORT), listenMultiple=True)

    log.warning("-----------------------------------------------------------------------")
    if settings.STRATUM_HOST == '0.0.0.0':
        log.warning("PROXY IS LISTENING ON ALL IPs ON PORT %d (stratum)" % settings.STRATUM_PORT)
    else:
        log.warning("LISTENING FOR MINERS ON stratum+tcp://%s:%d (stratum)" % \
                 (settings.STRATUM_HOST, settings.STRATUM_PORT))
    log.warning("-----------------------------------------------------------------------")
开发者ID:nikkiman,项目名称:xmr-proxy,代码行数:52,代码来源:xmr-proxy.py


示例19: main

def main():
  parser = argparse.ArgumentParser(
      description='OSC server to control some number of searchlights.')
  parser.add_argument('--config_file', type=argparse.FileType(), required=True,
                      help='YAML config file specifying how the searchlights are set up.')
  logging_common.add_logging_args(parser)
  args = parser.parse_args()

  logging_common.configure_logging_from_args(args)

  config = yaml.load(args.config_file)
  logging.info('Got config file: %s', pprint.pformat(config))

  if not config.get('configuration_database'):
    logging.error('Config file does not specify a searchlight configuration database.')
    return
  config_store = SearchlightConfigStore.create_with_sqlite_database(
      config.get('configuration_database'))

  osc_receiver = dispatch.Receiver()
  reactor.listenMulticast(
      config['osc_server']['port'],
      osc_server.MulticastDatagramServerProtocol(
          osc_receiver, config['osc_server']['address']),
      listenMultiple=True)

  if not config.get('searchlights'):
    logging.error('Config file specifies no searchlights.')
    return

  name_to_searchlight = {}
  for config_values in config.get('searchlights'):
    motor_controller = MotorController(reactor, **config_values.pop('motor_controller'))
    searchlight = Searchlight(motor_controller, osc_receiver, config_store, **config_values)
    name_to_searchlight[searchlight.name] = searchlight

  psmove_connection_manager = None
  psmove_controller_configs = config.get('psmove_controllers', [])
  if psmove_controller_configs:
    psmove_connection_manager = PSMoveConnectionManager(
        reactor, psmove_controller_configs, name_to_searchlight)

  if not config.get('admin_server_port'):
    logging.error('Config file does not specify administration server port.')
    return
  reactor.listenTCP(
      config.get('admin_server_port'),
      admin_server.AdminServer(name_to_searchlight.values()))

  reactor.run()
开发者ID:robgaunt,项目名称:flashlight,代码行数:50,代码来源:searchlight_main.py


示例20: start_multicast

def start_multicast():
    """
    Starts a :class:`Polo` instance for each multicast group configured in\
    conf.MULTICAST_ADDRS, initializing all the data structures
    """
    for group in conf.MULTICAST_ADDRS:
        offered_services[group] = []
        user_services[group] = {}
        polo = Polo(offered_services[group], user_services[group], group)
        polo_instances[group] = polo
        reactor.listenMulticast(conf.PORT,
                                polo,
                                listenMultiple=False,
                                interface=group)
开发者ID:Alternhuman,项目名称:marcopolo,代码行数:14,代码来源:polod.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reactor.listenSSL函数代码示例发布时间:2022-05-27
下一篇:
Python reactor.iterate函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap