title: receiving data over a python socket
body: <p>I'm making a program that retrieves decently large amounts of data through a python socket and then immediately disconnects when the information is finished sending. But I'm not sure how to do this</p>
  
  <p>All the examples on the web are of tcp clients where they have</p>
  
  <pre><code>while 1:
     data = sock.recv(1024)
  </code></pre>
  
  <p>But this creates a look to infinite loop to receive data via the socket, does it not?</p>
  
  <p>I need to figure out the size of the message coming in and loop through it in buffer-sized  increments to get the full message. And after the message has finished sending, I would like to disconnect, although i think the connection will be closed from the other end.
  Any help would be nice</p>
  
  <p>Thanks</p>