title: Python socket server/client not looping
body: <p>I'm working on a number guessing game handled over two clients connected via socket, but for some reason after the initial loop it stops working and doesn't send/receive anything. The code all executes fine the first time around, but no matter what I change, the second time around I either get an error at the line <code>guessNumber = int(s.recv(4096).decode()</code> in the server file - where it reports an error trying to change <code>''</code> into an int. This implies it's not receiving a value (in these instances, the Client program doesn't receive the <code>"What is your guess? "</code> string either).
  The code below however just doesn't do anything after that initial loop, If you guess the number on that first loop then it works fine, your score is written to a file and they both end as they should. </p>
  
  <p>But if you don't then it doesn't do anything either, so any help would be appreciated. It's running in Python 3.4.2 using the IDLE IDE.</p>
  
  <p>Server:</p>
  
  <pre><code>import socket
  import random
  
  l = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
  score = 0
  guessNumber = 0
  
  def within(value, goal, n):
      numDifference = abs(value - goal)
      if (numDifference &lt;= n):
          return True
      else:
          return False
  
  scoreFile = open('scores', 'a')
  randomNumber = random.randrange(0, 11)
  
  l.bind(("127.0.0.1", 4001)) 
  l.listen(5) 
  print("Waiting...")
  
  while True:
      (s,ca)=l.accept()   
      print("Connection from", ca)
  
      while (not(within(guessNumber, randomNumber, 0))):
          s.sendall("What is your guess? ".encode())
          guessNumber = int(s.recv(4096).decode())
          score += 1
  
          print ("%d" % guessNumber)
  
          if (within(guessNumber, randomNumber, 0)):
              s.sendall(("You guessed correctly! \n Your score is %d" % score).encode())
              scoreFile.write("Player %s has a score of %d \n" % (ca, score))
              scoreFile.close()
              s.sendall("1".encode())
          elif (within(guessNumber, randomNumber, 3)):
              s.sendall("You are getting close!".encode())
              s.sendall("0".encode())
          else:
              s.sendall("You are way off".encode())
              s.sendall("0".encode())
  
      s.close()  
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>import socket
  
  gameOver = False
  guessNumber = 0
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect(("127.0.0.1", 4001))
  
  while (gameOver != "1"):
      #Send guess
      guessNumber = input(s.recv(4096).decode()) 
      s.sendall(guessNumber.encode())
  
      #Recieve result
      print(s.recv(4096).decode())
  
      #Check whether game is over or not
      gameOver = s.recv(4096).decode()
  
  print ("Game Over")
  s.close()   
  </code></pre>