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


Python reactor.listenMulticast函数代码示例

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


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


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