title: How to pass information to and from RequestHandler in socket server
body: <p>I have a class that manages a socketserver. Information needs to be passed in both directions between it and the handler. There are some work arounds I can use to get the Handler to pass information to the game server, but not the other way around. It seems like a pretty common need. It's also possible that there's a better way to do this whole thing and that I'm violating some common practice, in which case I'd like to know so I can write my code in a more standard way (I'm not trying to do anything fancy).</p>
  
  <pre><code>class GameServer:
      class GameServerUDPHandler(socketserver.BaseRequestHandler):
          #... (other, irrelevant functions)
          def handle(self):
              data = self.request[0].strip()
              data = str(data, 'utf-8')
              print(data)
              socket = self.request[1]
              data = data.split('\n')
              option = data[0]
              print(option)
              c_add = self.client_address
              if option == "register" and not self.server.base.has_started:
                  self.handle_register(socket, c_add)
                  print("test")
              elif option == "get_postion":
                  handle_get_postion(socket, c_add, data[1])
              elif option == "change_postion":
                  hande_changed_postion(socket, c_add, data[1])
              #temporary
              if len(self.server.base.players) &gt; 0:
                  self.server.base.start
  
      def __init__(self, port):
          self.server = socketserver.UDPServer(("localhost", port), self.GameServerUDPHandler)
  
      def start_server(self):
          threading.Thread(target=self.server.serve_forever).start()
  
      def start_game():
          self.has_started = True
          self.server.RequestHandler.alert_start()
  </code></pre>