title: sockaddr structure - (sys/socket.h)
body: <p>Ive been reading the <a href="http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html" rel="noreferrer">sys/socket.h</a> all day and finally starting to understand it, and now starting to use it, however, I'm not sure why I can't assign a value to <code>sa_family</code> member of the <code>sockaddr</code> struct.</p>
  
  <p>Specification <code>sockaddr</code> Structure:</p>
  
  <pre><code>struct sockaddr{
      sa_family_t   sa_family       address family
      char          sa_data[]       socket address (variable-length data)
  };
  </code></pre>
  
  <p>Data Type:  <code>sa_family_t</code> - Unsigned integral type (2-4 bytes)</p>
  
  <p>Values:</p>
  
  <pre><code>Name                Purpose                          Man page
         AF_UNIX, AF_LOCAL   Local communication              unix(7)
         AF_INET             IPv4 Internet protocols          ip(7)
         AF_INET6            IPv6 Internet protocols          ipv6(7)
         AF_IPX              IPX - Novell protocols
         AF_NETLINK          Kernel user interface device     netlink(7)
         AF_X25              ITU-T X.25 / ISO-8208 protocol   x25(7)
         AF_AX25             Amateur radio AX.25 protocol
         AF_ATMPVC           Access to raw ATM PVCs
         AF_APPLETALK        AppleTalk                        ddp(7)
         AF_PACKET           Low level packet interface       packet(7)
         AF_ALG              Interface to kernel crypto API
  </code></pre>
  
  <p>Which is a bit confusing since these values are <code>char</code> data types not an <code>unsigned int</code>.</p>
  
  <p>Simple Test:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;sys/socket.h&gt; 
  
  int main(void){
      struct sockaddr_in address;
      address.sin_family = AF_INET;
      printf("Socket Address Family: %s\n", address.sin_family);
      return 0;
  }
  </code></pre>
  
  <p>Error: </p>
  
  <p><code>storage size of ‘address’ isn’t known</code></p>
  
  <p>It should be printing out <code>Socket Address Family: AF_INET</code>... what am I missing here?</p>