title: Python Game Server
body: <p>I'm completely lost trying to create a UDP server/client for my game in python. I'm new to the language and only have limited experience with networking. Right now, the server runs, but doesn't seem to be getting any messages from the client.</p>
  
  <p>Server:</p>
  
  <pre><code>class GameServer:
      class GameServerUDPHandler(socketserver.BaseRequestHandler):
          def handle(self):
              data = self.request[0].strip()
              socket = self.request[1]
              print("{} wrote:".format(self.client_address[0]))
              print(data)
              socket.sendto(data.upper(), self.client_address)
  
      def __init__(self, port):
          self.server = socketserver.UDPServer(("localhost", port), self.GameServerUDPHandler)
  
      def start_server(self):
          self.server.serve_forever(
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>import socket
  import sys
  
  class GameClient:
      def __init__(self, port, host):
          self.port = port
          self.host = host
          self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  
      def register(self):
          self.socket.sendto(bytes("register\n", "utf-8"), (self.host, self.port))
          self.numberID = int(self.socket.recv(1024))
          print("Received:   {}".format(self.numberID))
  </code></pre>
  
  <p>-Main/Start of program</p>
  
  <pre><code>import gameserver
  import gameclient
  
  if __name__ == "__main__":
      server = gameserver.GameServer(1300)
      server.start_server()
      client = gameclient.GameClient(1300, "localhost")
      client.register()
  </code></pre>
  
  <p>NOTE: I'm most likely to multiple things wrong and may be violating several best practices in the language. I really have no clue.</p>