title: How to detect SO_REUSEPORT availibility at run time?
body: <p>For instance linux <em>kernel-2.6.32-279</em> does not define SO_REUSEPORT in /usr/include/asm-generic/socket.h but <em>kernel-2.6.32-431</em> define it.</p>
  
  <p>Then if I build some code like :</p>
  
  <pre><code>#include &lt;sys/socket.h&gt;
  #include &lt;unistd.h&gt;
  
  int createsock()
  {
      int sock = socket(AF_INET, SOCK_DGRAM, 0);
  #ifdef SO_REUSEPORT
      int reuse = 1;
      if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,(const char*)&amp;reuse, sizeof(reuse)) &lt; 0) 
      {
          close(sock);
          return -1;
      }
  #endif
      return sock;
  }
  </code></pre>
  
  <p>The executable built with kernel-2.6.32-431, it works correctly with kernel-2.6.32-431, but doesnot work with kernel-2.6.32-279. 
  If it is built with kernel-2.6.32-279, it works on both.</p>
  
  <p>This code detect the option availability at build time, and it could be different at run time.</p>
  
  <p>What could be a way to detect at runtime ?</p>