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


Python socketserver.UDPServer方法代码示例

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


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

示例1: 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:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test_socketserver.py

示例2: __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

示例3: setUp

# 需要导入模块: import socketserver [as 别名]
# 或者: from socketserver import UDPServer [as 别名]
def setUp(self):
        self.server = socketserver.UDPServer(('127.0.0.1', 2003), TestHandler)
        self.server.timeout = 1.0 
开发者ID:Jetsetter,项目名称:graphyte,代码行数:5,代码来源:test_graphyte.py

示例4: server_bind

# 需要导入模块: import socketserver [as 别名]
# 或者: from socketserver import UDPServer [as 别名]
def server_bind(self):
        self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
        # UDPServer is old-style class so can't use super
        socketserver.UDPServer.server_bind(self) 
开发者ID:Yelp,项目名称:paasta,代码行数:6,代码来源:firewall_logging.py

示例5: __init__

# 需要导入模块: import socketserver [as 别名]
# 或者: from socketserver import UDPServer [as 别名]
def __init__(self, values={}, callback=None):
        socketserver.UDPServer.__init__(
            self, ('0.0.0.0', 53), RequestHandler
        )
        if callback is None:
            self.getRecord = self._getRecord
        else:
            self.getRecord = callback
        self.values = values 
开发者ID:LyleMi,项目名称:Saker,代码行数:11,代码来源:dnsrebinding.py

示例6: 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

示例7: open

# 需要导入模块: import socketserver [as 别名]
# 或者: from socketserver import UDPServer [as 别名]
def open(self, staged=False):
        """
        open the DNS server and listen for connections
        :param staged: should we stage first?
        :return: True if successfull
        """

        if not self.validate_options():
            return False

        # reset all internal values
        self.conn = None
        self.server = None
        self.staged = staged
        self.currentstagenum = 0
        self.currentnum = -1
        self.senddataqueue = DataQueue()
        self.recvdataqueue = DataQueue()
        self.progress = None
        self.maxstagenum = None
        self.laststagepart = None
        self.lastpart = None

        if not staged:
            self.currentstagenum = -1
        else:
            self.currentstagenum = 0

        # mark backchannel to us from each DnsHandler instance
        DnsHandler.transport = self

        lparams = (self.options['LHOST']['Value'], int(self.options['LPORT']['Value']))

        try:
            self.server = socketserver.UDPServer(lparams, DnsHandler)
        except PermissionError as e:
            print_error("Could not open DNS server on {}:{}: {}".format(lparams[0], lparams[1],
                                                                        str(e)))
            return False

        threading.Thread(target=self.server.serve_forever).start()

        print_message("DNS listening on {}:{}".format(lparams[0], lparams[1]))
        return True 
开发者ID:SySS-Research,项目名称:outis,代码行数:46,代码来源:dns.py


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