本文整理汇总了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)
示例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()
示例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()
示例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)
示例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
示例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)
示例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)
示例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)
示例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()
示例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)
示例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()
示例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())
示例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)
示例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)
示例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()