title: Python TCP 'Send' socket buffer size
body: <p>I want to send/receive 'portioned' data using TCP Python <code>socket</code> module.
  My receiving server side <code>socket</code> is set to receive 40 bytes of data in a single <code>recv</code> call:</p>
  
  <pre><code>while True:
      data = connection.recv(40)
      if not data:
          break
      ...
  connection.close()
  </code></pre>
  
  <p>I have some sample data ~500 bytes long, converter to <code>bytes</code> object, that is being sent to 'server' by 'client':</p>
  
  <pre><code>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  ...
  s.send(sample_data)
  </code></pre>
  
  <p>Although I only have one call to <code>send</code> method does it mean that client sends 40 bytes of 'sample_data' at a time while server 'requests' 40 bytes at once for as long as whole package is not sent completely?</p>
  
  <p>I found in <a href="https://stackoverflow.com/questions/30888397/how-to-set-send-buffer-size-for-sockets-in-python">this post</a> there's <code>SO_SNDBUF</code> parameter that sets size of <code>send</code> buffer for <code>socket</code>, but how is it different from 'ordinary' <code>socket</code> without <code>SO_SNDBUF</code> being set?</p>
  
  <pre><code>buffer_size = 40
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, buffer_size)
  ...
  s.send(sample_data)
  </code></pre>