Author: subinacls Language: text
Description: need to wrap this in tls Timestamp: 2013-06-18 15:49:56 +0000
View raw paste Reply
   try:
    class ThreadedUDPRequestHandler(SocketServer.BaseRequestHandler):
     def handle(self):
      self.data = self.request.recv(1024).strip()
      print bcolors.OKBLUE + "Host: %s connected on port: %s\n" % (self.client_address[0],self.data) + bcolors.ENDC
      self.request.send(self.data)
    class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
     def handle(self):
      self.data = self.request.recv(1024).strip()
      print bcolors.OKBLUE + "Host: %s connected on port: %s\n" % (self.client_address[0],self.data) + bcolors.ENDC
      self.request.send(self.data)
    class ThreadedUDPServer(SocketServer.ThreadingMixIn, SocketServer.UDPServer):
     pass
    class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
     pass
    socketserver = ThreadedUDPServer(('', lowport), ThreadedUDPRequestHandler)
    socketserver_thread = threading.Thread(target=socketserver.serve_forever)
    socketserver_thread.setDaemon(False)
    socketserver_thread.start()
    socketserver = ThreadedTCPServer(('', lowport), ThreadedTCPRequestHandler)
    socketserver_thread = threading.Thread(target=socketserver.serve_forever)
    socketserver_thread.setDaemon(False)
    socketserver_thread.start()
View raw paste Reply