title: Python network/socket programming, simple game
body: <p>Im trying to make a simple game but cant understand how to make it work and send more then one thing over the network. It works the first time but it supposed to go 10 times. It only sends 1 random number now but i want it to send one new when the game goes again and want a new number.</p>
  
  <p>Server </p>
  
  <pre><code>import socket, random               
  
  sock = socket.socket()
  host = socket.gethostname()
  port = 12345
  sock.bind((host, port))
  sock.listen(5)
  
  c, addr = sock.accept()
  
  cpu = random.choice(range(0, 3))
  c.send(cpu)
  
  gameon = c.recv(int(1024))
  </code></pre>
  
  <p>Client</p>
  
  <pre><code>import socket, random
  
  sock = socket.socket()  # Create a socket object
  host = socket.gethostname()  # Get local machine name
  port = 12345  # Reserve a port for your service.
  sock.connect((host, port))
  
  GAMEON = 'Rock', 'Paper', 'Scissors'
  game = 0
  iwin = 0
  ilose = 0
  tie = 0
  
  while game &lt; 10:
  
      for i in range(0, 3):
          print "%d %s" % (i + 1, GAMEON[i])
  
      player = int(input ("Choose from 1-3: ")) - 1
      cpu = int(sock.recv(1024))
      print cpu
  
      print""
  
      print "%s vs %s" % (GAMEON[player], GAMEON[cpu])
      print ""
      if cpu != player:
        if (player - cpu) % 3 &lt; (cpu - player) % 3:
          print "Player wins\n"
          iwin += 1
        else:
          print "CPU wins\n"
          ilose += 1
      else:
        print "TIE!\n"
        tie += 1 
      game += 1
      sock.send(str(game))
  print"Game is done"
  print"you win: ", (iwin), "Times"
  print"computer wins: ", (ilose), "Times"
  print"tie: ", (tie), "Times"
  </code></pre>