title: What does Python's socket.recv() return for non-blocking sockets if no data is received until a timeout occurs?
body: <p>Basically, I've read in several places that <code>socket.recv()</code> will return whatever it can read, or an empty string signalling that the other side has shut down  (the official docs don't even mention what it returns when the connection is shut down... great!). This is all fine and dandy for blocking sockets, since we know that <code>recv()</code> only returns when there actually is something to receive, so when it returns an empty string, it <strong>MUST</strong> mean the other side has closed the connection, right?</p>
  
  <p>Okay, fine, but what happens when my socket is non-blocking?? I have searched a bit (maybe not enough, who knows?) and can't figure out how to tell when the other side has closed the connection using a non-blocking socket. There seems to be no method or attribute that tells us this, and comparing the return value of <code>recv()</code> to the empty string seems absolutely useless... is it just me having this problem?</p>
  
  <p>As a simple example, let's say my socket's timeout is set to 1.2342342 (whatever non-negative number you like here) seconds and I call <code>socket.recv(1024)</code>, but the other side doesn't send anything during that 1.2342342 second period. The <code>recv()</code> call will return an empty string and I have no clue as to whether the connection is still standing or not...</p>