title: getsockopt() returns a value twice the value that was previously set by setsockopt()
body: <p>I am attempting to increase the <code>SO_RCVBUF</code> for a raw socket I am using to interact with a linux device driver. The default <code>rmem_default/rmem_max</code> are both too small, 163840. Therefore I am using the following <a href="https://stackoverflow.com/questions/10063497/why-changing-value-of-so-rcvbuf-doesnt-work">stack overflow question/answers</a> to help me. Everything is working, or least it looks like it. However, when I get the value I set for the <code>SO_RCVBUF</code> it returns the value I set * 2? Anyone know why that is?</p>
  
  <pre><code>int recv_val = SOCK_RCV_BUF_MAX; socklen_t size = sizeof(recv_val);
  
  if(setsockopt(sock_fd, SOL_SOCKET, SO_RCVBUF, &amp;recv_val, size) &lt; 0)
  {
      fprintf(stderr, "Error setsockopt(SO_RCVBUF): %s\n", strerror(errno));
  }
  else
      printf("Set the SO_RCVBUF to %d\n", recv_val);
  
  recv_val = 0;
  
  if (getsockopt(sock_fd, SOL_SOCKET, SO_RCVBUF, &amp;recv_val, &amp;size) &lt; 0)
  {
      fprintf(stderr, "Error getsockopt(SO_RCVBUF): %s\n", strerror(errno));
  }
  else if(recv_val == SOCK_RCV_BUF_MAX)
  {
      printf("Successfully set the buffer max to %d\n", SOCK_RCV_BUF_MAX);
  }
  else
      printf("Failed to set the buffer to max (%d), val = %d\n", SOCK_RCV_BUF_MAX, recv_val);
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Set the SO_RCVBUF to 64000000
  Failed to set the buffer to max (64000000), val = 128000000
  </code></pre>
  
  <p>Changing to <code>recv_val = SOCK_RCV_BUF_MAX/2</code> outputs</p>
  
  <pre><code>Set the SO_RCVBUF to 32000000
  Successfully set the buffer max to 64000000
  </code></pre>
  
  <p>If I don't set the value using setsockopt() and call getsockopt() for my socket I get the correct default value</p>
  
  <pre><code>Failed to set the buffer to max (64000000), val = 163840
  </code></pre>