本文整理汇总了Python中twisted.internet.reactor.listenUDP函数的典型用法代码示例。如果您正苦于以下问题:Python listenUDP函数的具体用法?Python listenUDP怎么用?Python listenUDP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了listenUDP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, address = None, data_callback = None):
self.data_callback = data_callback
if address == None:
reactor.listenUDP(0, self)
else:
reactor.listenUDP(address[1], self, address[0])
filterwarnings('ignore', '^Please only pass')
开发者ID:gtkiller,项目名称:b2bua,代码行数:7,代码来源:Udp_server.py
示例2: _realise_connection
def _realise_connection(cls, async):
"""Return a configured statsd client connection."""
servers = config.statsd.servers
if servers is None:
raise LookupError('Unable to obtain the statsd configuration')
servers = map(None, [server.strip() for server in servers.split(";")])
if not servers:
raise LookupError('Unable to obtain the statsd configuration')
connections = []
for server in servers:
statsd_host, statsd_port = server.split(":")
statsd_port = int(statsd_port)
if async:
connection = TwistedStatsDClient.create(statsd_host,
statsd_port)
connection.disconnect_callback = \
lambda: cls._disconnect_connection(connection)
protocol = StatsDClientProtocol(connection)
from twisted.internet import reactor
reactor.listenUDP(0, protocol)
else:
connection = UdpStatsDClient(statsd_host, statsd_port)
connection.connect()
connections.append(connection)
if len(connections) == 1:
return connections[0]
return ConsistentHashingClient(connections)
开发者ID:cloudfleet,项目名称:filesync-server,代码行数:34,代码来源:metricsconnector.py
示例3: nda_loop
def nda_loop():
ndutil.setTimezone()
ndlCom = NdlCom('nDroid-Executer', '127.0.0.1', 12322)
ndlCom.doCom('Initiating')
ndlCom.doCom('Loading Config')
cnfManager = CnfManager()
cnfManager.load('./nde.cnf')
cnfData = cnfManager.getCnfData()
nsQueue = Queue()
nsLock = threading.Lock()
netManager = NetManager()
netManager.setNdlCom(ndlCom)
netManager.setNsQueue(nsQueue, nsLock)
ndlCom.doCom('Starting Threads')
scheduler = Scheduler([ndlCom, nsQueue, nsLock], 'Scheduler')
scheduler.start()
reactor.listenUDP(cnfData['comPort'], netManager)
ndlCom.doCom('Listening Com Port')
reactor.run()
scheduler.join()
开发者ID:jovistar,项目名称:nDroid-Executer,代码行数:28,代码来源:nde.py
示例4: run_auth
def run_auth(self):
"""run auth
"""
auth_protocol = RADIUSAccess(self.config)
task.LoopingCall(auth_protocol.process_delay).start(2.7)
reactor.listenUDP(int(self.config.radiusd.auth_port), auth_protocol, interface=self.config.radiusd.host)
reactor.run()
开发者ID:actcms,项目名称:toughwlan,代码行数:7,代码来源:radiusd.py
示例5: main
def main(type):
log.startLogging(sys.stderr, setStdout=False)
if type == "1":
client_factory = client_server.Factory()
reactor.connectTCP('127.0.0.1', 8125, client_factory)
else :
client_factory = client_server.FactoryUDP()
reactor.listenUDP(0, client_factory)
def wait_for_protocol():
while len(client_factory.instances) == 0:
time.sleep(1)
return True
d = threads.deferToThread(wait_for_protocol)
def run_loop(_):
proc = CommandProcessor(client_factory.instances[0])
reactor.callInThread(proc.cmdloop)
d.addCallback(run_loop)
reactor.run()
开发者ID:danielkza,项目名称:mac0448-chat,代码行数:26,代码来源:client.py
示例6: connectionMade
def connectionMade(self):
self.sms_queue = defer.DeferredQueue()
self.sip_queue = defer.DeferredQueue()
self.sms_queue.get().addCallback(self.sipClientDataReceived)
self.sip_client_factory = SIPProxyClientProtocol(self.sms_queue, self.sip_queue)
from twisted.internet import reactor
reactor.listenUDP(5062, self.sip_client_factory)
开发者ID:kluchnikov,项目名称:sms-proxy,代码行数:7,代码来源:sms-proxy.py
示例7: setUpForATest
def setUpForATest(self,
ServerProtocol=TestProtocol, ClientProtocol=TestProtocol):
serverProto = ServerProtocol()
clientProto = ClientProtocol()
self.serverProto = serverProto
self.clientProto = clientProto
sf = protocol.ServerFactory()
sf.protocol = lambda: serverProto
cf = Django()
cf.protocol = lambda: clientProto
serverTransport = ptcp.PTCP(sf)
clientTransport = ptcp.PTCP(None)
self.serverTransport = serverTransport
self.clientTransport = clientTransport
serverPort = reactor.listenUDP(0, serverTransport)
clientPort = reactor.listenUDP(0, clientTransport)
self.clientPort = clientPort
self.serverPort = serverPort
return (
serverProto, clientProto,
sf, cf,
serverTransport, clientTransport,
serverPort, clientPort
)
开发者ID:derwolfe,项目名称:vertex,代码行数:33,代码来源:test_ptcp.py
示例8: listen
def listen(self):
# Listen on UDP port
logging.info('AgentListener: Trying to listen UDP on port %s',\
str(self.udp_port))
try:
reactor.listenUDP(self.udp_port, AgentDatagramProtocol(self))
logging.info('AgentListener: Listening UDP on port %s',\
str(self.udp_port))
except:
logging.error('AgentListener: Failed to listen UDP on port %s',\
str(self.udp_port))
# Make sure we have enabled SSL
if not self.ssl_enabled:
return
# Listen on SSL port
ssl_factory = Factory()
AgentSSLProtocol.agent_listener = self
ssl_factory.protocol = AgentSSLProtocol
ssl_context_factory = twisted.internet.ssl.DefaultOpenSSLContextFactory(\
self.key_file_name, self.cert_file_name)
logging.info('AgentListener: Trying to listen SSL on port %s',\
str(self.ssl_port))
try:
reactor.listenSSL(self.ssl_port, ssl_factory, ssl_context_factory)
logging.info('AgentListener: Listening SSL on port %s',\
str(self.ssl_port))
except:
logging.error('AgentListener: Failed to listen SSL on port %s',\
str(self.ssl_port))
开发者ID:umitproject,项目名称:network-inventory,代码行数:31,代码来源:AgentListener.py
示例9: main
def main():
print "AndroidProxy --- (C) Mathy Vanhoef"
print "This program comes with ABSOLUTELY NO WARRANTY."
print
print "DNS server will listen on localhost:53"
print "HTTP Proxy will listen on localhost:8007"
print
#print "Physical device: Configure your computer dns server and as router (NOT as proxy) and execute"
#print "\tiptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8007"
#print "\tiptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8007"
#print
print "Emulator: start it using: emulator @AvdName -http-proxy http://localhost:8007 -dns-server localhost"
print
print "Don't forget to start your normal proxy on localhost:8080"
print
# Setup custom DNS server
resolvers = []
resolvers.append(ProxyResolver([('8.8.8.8', 53)]))
f = server.DNSServerFactory(clients=resolvers)
p = dns.DNSDatagramProtocol(f)
reactor.listenUDP(53, p)
# Setup TCP proxy server
endpoint = TCP4ServerEndpoint(reactor, 8007)
endpoint.listen(ProxyFactory('localhost', 8080))
# Start DNS and TCP server
reactor.run();
开发者ID:divdby0,项目名称:androidproxy,代码行数:29,代码来源:main.py
示例10: main
def main():
reactor.listenTCP(8000, IPBusServerFactory())
reactor.listenUDP(8000, IPBusServerProtocol())
reactor.run()
reactor.stop()
开发者ID:kratsg,项目名称:ironman,代码行数:7,代码来源:ipbus.py
示例11: main
def main():
controls_client = ControlsClient("127.0.0.1", 10301)
reactor.listenUDP(0, controls_client)
simulator_data_client = SimulatorDataClient()
reactor.listenUDP(10302, simulator_data_client)
altitude = 300.0
airspeed = 30.0
waypoints = []
with open("waypoints.csv", "r") as f:
reader = csv.reader(f, delimiter=",")
for row in reader:
waypoint = [float(row[1]), float(row[2]), altitude, airspeed]
waypoints.append(waypoint)
autopilot = Autopilot(waypoints)
autopilot_adapter = AutopilotAdapter(autopilot, controls_client)
simulator_data_client.add_simulator_data_listener(autopilot_adapter)
log_updater = task.LoopingCall(autopilot.print_log)
log_updater.start(1.0)
simulator_control = SimulatorControlClient("localhost", 8090)
simulator_control.reset()
simulator_control.resume()
reactor.run()
开发者ID:pmatigakis,项目名称:Huginn,代码行数:34,代码来源:start_autopilot.py
示例12: main
def main():
global database
global port
init()
log()
# Create connection to the Mongo DB
try:
client = MongoClient('localhost', 27017)
# Creating the database for the server
db = client[serverName]
collection = db['users']
# Access the user collection from the database
database = db.users
except:
logger.error("Cannot access the Mongo database.")
raise SystemExit
try:
reactor.listenUDP(port, mySensorUDPServer())
reactor.run(installSignalHandlers=False)
except Exception, e:
tkMessageBox.showinfo("SCPP Message", "Server All Ready Started")
# logger.info(_('Switch Shut Down'))
reactor.callFromThread(reactor.stop)
pass
开发者ID:umayanga123,项目名称:scpp_python_node,代码行数:29,代码来源:scpp_switch.py
示例13: send
def send(self, oscmsg):
# print "send: " + str(oscmsg)
if self.transport == None:
# bij eerste keer zenden het protocol starten
reactor.listenUDP(0, self)
# OSC bericht encoderen en versturen
self.transport.write(oscmsg.getBinary()) # no need for address
开发者ID:hfmanson,项目名称:twisted-programs,代码行数:7,代码来源:datadirigent.py
示例14: test_connect_to_other
def test_connect_to_other():
f1 = ConnectedUDPFactory(TestProtocol)
conn_proto1 = ConnectedUDPProtocol(f1, TestDatagram())
conn_proto1_addr = ("127.0.0.1", 7778)
active_proto1 = TestProtocol()
f2 = ConnectedUDPFactory(TestProtocol)
conn_proto2 = ConnectedUDPProtocol(f2, TestDatagram())
conn_proto2_addr = ("127.0.0.1", 7779)
active_proto2 = TestProtocol()
def make_connection1():
conn_proto1.connect("127.0.0.1", conn_proto2_addr[1], active_proto1)
def send_later1():
active_proto1.write_data("sent test data")
def send_much_later1():
active_proto1.write_data("sent test data much later")
def close_connection1():
active_proto1.close_connection()
def make_connection2():
conn_proto2.connect("127.0.0.1", conn_proto1_addr[1], active_proto2)
def send_later2():
active_proto2.write_data("sent test data")
def send_much_later2():
active_proto2.write_data("sent test data much later")
def close_connection2():
active_proto2.close_connection()
from twisted.internet import reactor
def stop():
reactor.stop()
reactor.listenUDP(conn_proto1_addr[1], conn_proto1)
reactor.listenUDP(conn_proto2_addr[1], conn_proto2)
reactor.callLater(1, make_connection1)
reactor.callLater(5, send_later1)
reactor.callLater(10, send_much_later1)
reactor.callLater(15, close_connection1)
reactor.callLater(20, make_connection2)
reactor.callLater(25, send_later2)
reactor.callLater(30, send_much_later2)
reactor.callLater(35, close_connection2)
reactor.callLater(40, stop)
print "prepared for run"
reactor.run()
print "stopped"
return
开发者ID:imatsko,项目名称:BitTalks,代码行数:60,代码来源:connected_udp.py
示例15: StartUdpServer
def StartUdpServer(context, identity=None, address=None,
defer_reactor_run=False, custom_functions=[], **kwargs):
"""
Helper method to start the Modbus Async Udp server
:param context: The server data context
:param identify: The server identity to use (default empty)
:param address: An optional (interface, port) to bind to.
:param ignore_missing_slaves: True to not send errors on a request \
to a missing slave
:param defer_reactor_run: True/False defer running reactor.run() as part \
of starting server, to be explictly started by the user
:param custom_functions: An optional list of custom function classes
supported by server instance.
"""
from twisted.internet import reactor
address = address or ("", Defaults.Port)
framer = kwargs.pop("framer", ModbusSocketFramer)
server = ModbusUdpProtocol(context, framer, identity, **kwargs)
for f in custom_functions:
server.decoder.register(f)
_logger.info("Starting Modbus UDP Server on %s:%s" % address)
reactor.listenUDP(address[1], server, interface=address[0])
if not defer_reactor_run:
reactor.run(installSignalHandlers=_is_main_thread())
开发者ID:bashwork,项目名称:pymodbus,代码行数:27,代码来源:asynchronous.py
示例16: main
def main(argv):
sCFGName = 'mosul.cfg'
mosulConfig = ConfigParser.RawConfigParser()
mosulConfig.read(sCFGName)
sSyntax = os.path.basename(__file__) +" -n <stand_pipe_number> [-h for help]"
try:
opts, args = getopt.getopt(argv,"hn:",["number="])
except getopt.GetoptError:
print sSyntax
sys.exit(1)
if len(opts) < 1:
print sSyntax
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print sSyntax
sys.exit()
elif opt in ("-n", "--number"):
nStandpipe = int(arg)
if nStandpipe:
export_file = mosulConfig.get('DEMODATA','export_file')
port = mosulConfig.getint('DEMODATA','port')
server_host = mosulConfig.get('DEMODATA','server_host')
protocol = Standpipe()
protocol.m_init(server_host, port, nStandpipe,export_file)
reactor.listenUDP(port+nStandpipe+1, protocol)
reactor.run()
开发者ID:andreadanzi,项目名称:epbm,代码行数:29,代码来源:standpipe_client.py
示例17: announce
def announce(self, torrent):
self.torrent = torrent
host = yield reactor.resolve(self.host, timeout=(1, 3))
self.host = host
reactor.listenUDP(self.factory.track_port, self)
peers = yield self.deferred
defer.returnValue(peers)
开发者ID:jschneier,项目名称:TwistedTorrent,代码行数:7,代码来源:tracker.py
示例18: run
def run( self ):
if self.args.eyetracker:
reactor.listenUDP( 5555, self.client )
self.calibrator.start( self.start )
else:
self.start( None )
reactor.run()
开发者ID:RyanHope,项目名称:missile-defence,代码行数:7,代码来源:missile_defence.py
示例19: main
def main():
'''
Main test function
'''
# This section is only for logging stuff
# logger = NukeboxLogger('Client FileTX')
# Test Files
# fname = "05 ELECTRICBLOOM.mp3"
fname = "01 (THE FRENCH OPEN).mp3"
# fname = "02 CASSIUS.mp3"
# fname = "03 RED SOCKS PUGIE.mp3"
# fname = "08 TWO STEPS TWICE.mp3"
# Invalid File Format
# fname = "jukebox_client.log"
filesize = os.path.getsize(fname)
if filesize == 0:
print('File has No Content! :( ')
os._exit(1)
factory = NukeBoxClientFactory(fname)
print('*** Client Running ***')
udp_protocol = NukeBoxClientBroadcastProtocol(factory)
reactor.listenUDP(0, udp_protocol)
reactor.run()
开发者ID:Spankalish,项目名称:NukeBox2000,代码行数:32,代码来源:twistedClient.py
示例20: run
def run(self):
if config._get(config, 'sslcert', False):
with open(config.sslcert.certificate_file, 'rb') as fp:
cert = fp.read()
certificate = ssl.PrivateCertificate.loadPEM(cert)
co = certificate.options()
ssl_cert_options = ssl.CertificateOptions(co.privateKey, co.certificate, method=SSLv23_METHOD)
tls_cert_options = co
for proto_config in config.protocols:
factory = get_class_from_string(proto_config.factory)(proto_config, tls_cert_options, ssl_cert_options)
if proto_config.ssl and factory.supports_ssl:
reactor.listenSSL(proto_config.ssl.port, factory, ssl_cert_options)
if config._get(proto_config, 'transport') and proto_config.transport.lower() == 'udp':
reactor.listenUDP(proto_config.port, factory)
elif config._get(proto_config, 'tls') and proto_config.tls.enable and factory.supports_tls:
factory.options = tls_cert_options
reactor.listenTCP(proto_config.port, factory)
else:
reactor.listenTCP(proto_config.port, factory)
reactor.run()
开发者ID:spuriousdata,项目名称:slim,代码行数:25,代码来源:listener.py
注:本文中的twisted.internet.reactor.listenUDP函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论