title: How to detect Socket/connection is closed abruptly in Python 3.6
body: <p>How can I check if the client disconnects abruptly in Python 3.6. Here is my code,</p>
  
  <pre><code>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  print('Socket created')
  
  try:
      s.bind((HOST, PORT))
      print('Socket binding complete')
  except socket.error as socketError:
      print('socket binding failed, ', socketError)
  
  s.listen(1)
  print('Socket listening for connection...')
  
  conn, addr = s.accept()
  conn.setblocking(0)
  print('connected to ', addr[0])
  
  try:
      while True:
          temp = conn.recv(1024)
          if not temp:
              break
          data = int.from_bytes(temp, byteorder='big', signed=True)
          print('value received,', temp)
          print('converted value = ', data)
  except Exception as loopException:
      print("Exception occurred in loop, exiting...", loopException)
  finally:
      conn.close()
      s.close()
  </code></pre>
  
  <p>This is working if the client disconnects normally, It is properly closing the connection. How can I check if the client disconnects abruptly? </p>