title: Getting Errno 9: Bad file descriptor in python socket
body: <p>My code is this:</p>
  
  <pre><code>while 1:
      # Determine whether the server is up or down
      try:
          s.connect((mcip, port))
          s.send(magic)
          data = s.recv(1024)
          s.close()
          print data
      except Exception, e:
          print e
      sleep(60)
  </code></pre>
  
  <p>It works fine on the first run, but gives me Errno 9 every time after. What am I doing wrong?</p>
  
  <p>BTW,</p>
  
  <pre><code>mcip = "mau5ville.com"
  port = 25565
  magic = "\xFE"
  </code></pre>