title: Buffer size for reading UDP packets in Python
body: <p>I am trying to find out / adjust the size of network buffers:</p>
  
  <pre><code>import socket
  
  sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
  
  sock.getsockopt(socket.SOL_SOCKET,socket.SO_RCVBUF)
  212992
  </code></pre>
  
  <p>What on earth is this?  ~ 0.2 MBytes ..!?</p>
  
  <p>However, if I am looking for the buffer size elsewhere, i.e. on the command line:</p>
  
  <pre><code>sampsa@sampsa-xps13:~/python/sockets$ cat /proc/sys/net/ipv4/tcp_wmem
  4096    16384   4194304
  </code></pre>
  
  <p>.. I get 4096 bytes.</p>
  
  <p>Let's try to set the buffer size and then check its value:</p>
  
  <pre><code>sock.setsockopt(socket.SOL_SOCKET,socket.SO_RCVBUF,1024)
  
  sock.getsockopt(socket.SOL_SOCKET,socket.SO_RCVBUF)     
  2304
  </code></pre>
  
  <p>What's going on?</p>
  
  <p>Substituting SOL_SOCKET with SOL_UDP gives "Protocol not available"</p>
  
  <p>How can I adjust the max. size of the UDP packet .. or even find it out?</p>