title: How does the python socket.recv() method know that the end of the message has been reached?
body: <p>Let's say I'm using 1024 as buffer size for my client socket:</p>
  
  <pre><code>recv(1024)
  </code></pre>
  
  <p>Let's assume the message the server wants to send to me consists of 2024 bytes. 
  Only 1024 bytes can be received by my socket. What's happening to the other    1000 bytes? </p>
  
  <ol>
  <li>Will the recv-method wait for a certain amount of time (say 2 seconds) for more data to come and stop working after this time span? (I.e., if the rest of the data arrives after 3 seconds, the data will not be received by the socket any more?)  </li>
  </ol>
  
  <p>or </p>
  
  <ol start="2">
  <li>Will the recv-method stop working immediately after having received 1024 bytes of data? (I.e. will the other 1000 bytes be discarded?)</li>
  </ol>
  
  <p>In case that 1.) is correct ... is there a way for me to to determine the amount of time, the recv data should wait before returning or is it determined by the system? (I.e. could I tell the socket to wait for 5 seconds before stopping to wait for more data?)  </p>
  
  <p>UPDATE:
  Assume, I have the following code:</p>
  
  <pre><code>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      s.connect((sys.argv[1], port))
      s.send('Hello, world')
      data = s.recv(1024)
      print("received: {}".format(data))
      s.close()
  </code></pre>
  
  <p>Assume that the server sends data of size > 1024 bytes. Can I be sure that the variable "data" will contain all the data (including those beyond the 1024th byte)?
  If I can't be sure about that, how would I have to change the code so that I can always be sure that the variable "data" will contain all the data sent (in one or many steps) from the server? </p>