title: Isn't struct sockadr_in supposed to work for both IPv4 and IPv6?
body: <p>Specifically sin_addr seems to be located on different memory locations for IPv4 and IPv6 socket addressed. This results in weirdness:</p>
  
  <pre><code>#include &lt;stdio.h&gt;                                                                               
  #include &lt;netinet/in.h&gt;                                                                          
  
  int main(int argc, char ** argv) {                                                               
    struct sockaddr_in sa;                                                                         
    printf("sin_addr in sockaddr_in  = %p\n", &amp;sa.sin_addr);                                       
    printf("sin_addr in sockaddr_in6 = %p\n", &amp;((struct sockaddr_in6*)&amp;sa)-&gt;sin6_addr);            
  };
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>sin_addr in sockaddr_in  = 0x7fffa26102b4
  sin_addr in sockaddr_in6 = 0x7fffa26102b8
  </code></pre>
  
  <p>Why aren't these 2 values the same ?</p>
  
  <p>Since this is pointing to the same data (the address to connect to), this should be located at the same address. Otherwise, how are you supposed to call inet_ntop with a sockaddr_in that you don't know is IPv4 or IPv6 ?</p>