title: Python client server how UDP is supposed to work?
body: <p>I have a client-server "snake" game working really well with TCP connections, and I would like to try it the UDP way.</p>
  
  <p>I wonder how it is supposed to be used ? I know how UDP works, how to make a simple ECHO example, but I wonder how to do the following : </p>
  
  <p>For instance with TCP, every TICK (1/15 second) server sends to the client the new Snake head position.</p>
  
  <p>With UDP, am I supposed to do something like this :</p>
  
  <p>Client SIDE :</p>
  
  <pre><code>client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  serverAddr = (('localhost', PORT))
  while 1:
      client.sendto('askForNewHead', serverAddr)
      msg, addrServer = client.recvfrom(1024)
      game.addPosition(msg)
  </code></pre>
  
  <p>Server SIDE :</p>
  
  <pre><code>server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  server.bind((HOST, PORT))
  while 1:
      data, addr = server.recvfrom(1024)
      server.sendto(headPosition, addr)
  </code></pre>
  
  <p>So here Client has to ask server to get the new head position, and then server sends the answer. I managed to make it work this way, but I can't figure out if it is a good way of doing. </p>
  
  <p>Seems weird that client has to ask udp for an update while with my TCP connection, client has just to wait untill he receives a message.</p>