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


Python SocketServer.UDPServer方法代码示例

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


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

示例1: run

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def run(self, ttl=None):
        if self.DISABLE_SSDP_LISTENER:
            return

        self.allow_reuse_address = True
        SocketServer.UDPServer.__init__(
            self, (self.host or '', self.SSDP_PORT), SSDPHandler)
        self.socket.setsockopt(
            socket.IPPROTO_IP,
            socket.IP_ADD_MEMBERSHIP,
            self._multicast_struct(self.SSDP_ADDRESS))
        self.socket.setsockopt(
            socket.IPPROTO_IP,
            socket.IP_MULTICAST_TTL,
            self.SSDP_TTL)

        if ttl:
            GObject.timeout_add(ttl * 1000, self.shutdown)

        setproctitle.setproctitle('ssdp_listener')
        self.serve_forever(self)
        logger.info('SSDPListener.run()') 
开发者ID:masmu,项目名称:pulseaudio-dlna,代码行数:24,代码来源:listener.py

示例2: run_udp

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def run_udp(realport, fakeport, handler):
	class SingleUDPHandler(SocketServer.BaseRequestHandler):
		def handle(self):
			srcaddr, srcport = self.client_address
			print("Packet from {}:{}".format(srcaddr, srcport))
			handler(self.request[1], self.request[0], self.client_address, fakeport)

	class SimpleServer(SocketServer.ThreadingMixIn, SocketServer.UDPServer):
		daemon_threads = True

		def __init__(self, server_address, RequestHandlerClass):
			SocketServer.UDPServer.__init__(self, server_address, RequestHandlerClass)

	server = SimpleServer(('127.0.0.1', realport), SingleUDPHandler)
	try:
		server.serve_forever()
	except KeyboardInterrupt:
		sys.exit(0) 
开发者ID:fabio-d,项目名称:honeypot,代码行数:20,代码来源:testrun.py

示例3: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def __init__(self,
                 server_address=dwc_config.get_ip_port('GameSpyNatNegServer'),
                 RequestHandlerClass=GameSpyNatNegUDPServerHandler,
                 bind_and_activate=True):
        SocketServer.UDPServer.__init__(self,
                                        server_address,
                                        RequestHandlerClass,
                                        bind_and_activate)
        self.session_list = {}
        self.natneg_preinit_session = {}
        self.secret_key_list = gs_utils.generate_secret_keys("gslist.cfg")

        self.server_manager = GameSpyServerDatabase(
            address=dwc_config.get_ip_port('GameSpyManager'),
            authkey=""
        )
        self.server_manager.connect()

        self.write_queue = Queue.Queue()
        threading.Thread(target=self.write_queue_worker).start() 
开发者ID:barronwaffles,项目名称:dwc_network_server_emulator,代码行数:22,代码来源:gamespy_natneg_server.py

示例4: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def __init__(self, server_address, RequestHandlerClass, nametodns, nameservers, ipv6, log):
        self.nametodns  = nametodns
        self.nameservers = nameservers
        self.ipv6        = ipv6
        self.address_family = socket.AF_INET6 if self.ipv6 else socket.AF_INET
        self.log = log

        SocketServer.UDPServer.__init__(self,server_address,RequestHandlerClass) 
开发者ID:GoSecure,项目名称:break-fast-serial,代码行数:10,代码来源:dnschef.py

示例5: test_UDPServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def test_UDPServer(self):
        self.run_server(SocketServer.UDPServer,
                        SocketServer.DatagramRequestHandler,
                        self.dgram_examine) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_socketserver.py

示例6: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def __init__(self, address):
        socketserver.UDPServer.__init__(self, address, RequestHandlerUdp) 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:4,代码来源:syslog_server.py

示例7: main

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def main():
    args = parse_args()
    fd = open(args.output_fname, 'a') if args.output_fname else None
    StatsdMessageHandler._output_fd = fd
    server = SocketServer.UDPServer(
        (args.addr, args.port),
        StatsdMessageHandler,
    )
    server.serve_forever() 
开发者ID:openstack,项目名称:designate,代码行数:11,代码来源:statsd_mock_server.py

示例8: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def __init__(self, server_address, MyUDPHandler):
		self.quarkqueue = {}
		SocketServer.UDPServer.__init__(self, server_address, MyUDPHandler) 
开发者ID:poliva,项目名称:ggposrv,代码行数:5,代码来源:ggposrv.py

示例9: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def __init__(self,options):
		SocketServer.UDPServer.__init__(self, ('0.0.0.0', 53), self.sHandle)
		self.timeout = 3
		self.options = options 
开发者ID:Tr3jer,项目名称:dnsAutoRebinding,代码行数:6,代码来源:main.py

示例10: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def __init__(self, server_address, config, logger, RequestHandlerClass):
        self.config = config
        self.logger = logger
        SocketServer.UDPServer.__init__(self, server_address, RequestHandlerClass) 
开发者ID:fireeye,项目名称:flare-fakenet-ng,代码行数:6,代码来源:DNSListener.py

示例11: start

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def start(self):
        server = SocketServer.UDPServer(("0.0.0.0", 53), DNSUDPHandler)
        server.serve_forever() 
开发者ID:opensec-cn,项目名称:vtest,代码行数:5,代码来源:vtest.py

示例12: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def __init__(self, server_address, RequestHandlerClass):
        self.address_family = socket.AF_INET6 if DNSChef().ipv6 else socket.AF_INET

        SocketServer.UDPServer.__init__(self,server_address,RequestHandlerClass) 
开发者ID:paranoidninja,项目名称:piSociEty,代码行数:6,代码来源:DNS.py

示例13: test_logging

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import UDPServer [as 别名]
def test_logging(self):
        """
        Test logging.
        """

        messages = []

        class SyslogHandler(socketserver.BaseRequestHandler):
            """
            Save received messages.
            """

            def handle(self):
                messages.append(self.request[0].strip().decode())

        syslog = socketserver.UDPServer(('0.0.0.0', 0), SyslogHandler)
        try:
            threading.Thread(target=syslog.serve_forever).start()

            env = os.environ.copy()
            env['SYSLOG_SERVER'] = syslog.server_address[0]
            env['SYSLOG_PORT'] = str(syslog.server_address[1])
            env['SYSLOG_PROTO'] = 'udp'

            mydir = os.path.dirname(__file__)

            supervisor = subprocess.Popen(
                ['supervisord', '-c', os.path.join(mydir, 'supervisord.conf')],
                env=env,
            )
            try:

                sleep(3)

                pid = subprocess.check_output(
                    ['supervisorctl', 'pid', 'messages']
                ).decode().strip()

                sleep(8)

                self.assertEqual(
                    list(map(strip_volatile, messages)),
                    ['<14>DATE HOST messages[{pid}]: Test {i} \n\x00'.format(
                        pid=pid,
                        i=i)
                     for i in range(4)]
                )
            finally:
                supervisor.terminate()

        finally:
            syslog.shutdown() 
开发者ID:infoxchange,项目名称:supervisor-logging,代码行数:54,代码来源:test_supervisor_logging.py


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