Python socketserver.UDPServer() Examples
The following are 11
code examples of socketserver.UDPServer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
socketserver
, or try the search function
.
Example #1
Source File: syslog_server.py From avocado-vt with GNU General Public License v2.0 | 5 votes |
def __init__(self, address): socketserver.UDPServer.__init__(self, address, RequestHandlerUdp)
Example #2
Source File: test_graphyte.py From graphyte with MIT License | 5 votes |
def setUp(self): self.server = socketserver.UDPServer(('127.0.0.1', 2003), TestHandler) self.server.timeout = 1.0
Example #3
Source File: test_socketserver.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_UDPServer(self): self.run_server(socketserver.UDPServer, socketserver.DatagramRequestHandler, self.dgram_examine)
Example #4
Source File: firewall_logging.py From paasta with Apache License 2.0 | 5 votes |
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)
Example #5
Source File: test_socketserver.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_UDPServer(self): self.run_server(socketserver.UDPServer, socketserver.DatagramRequestHandler, self.dgram_examine)
Example #6
Source File: dnsrebinding.py From Saker with GNU General Public License v3.0 | 5 votes |
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
Example #7
Source File: dnsrebinding.py From Saker with GNU General Public License v3.0 | 5 votes |
def __init__(self): socketserver.UDPServer.__init__( self, ('0.0.0.0', 53), RequestHandler )
Example #8
Source File: test_socketserver.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_UDPServer(self): self.run_server(socketserver.UDPServer, socketserver.DatagramRequestHandler, self.dgram_examine)
Example #9
Source File: test_socketserver.py From android_universal with MIT License | 5 votes |
def test_UDPServer(self): self.run_server(socketserver.UDPServer, socketserver.DatagramRequestHandler, self.dgram_examine)
Example #10
Source File: test_supervisor_logging.py From supervisor-logging with Apache License 2.0 | 4 votes |
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()
Example #11
Source File: dns.py From outis with MIT License | 4 votes |
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