title: Why is sin_addr inside the structure in_addr?
body: <p>My doubt is related to the following structure of sockets in UNIX :</p>
  
  <pre><code>struct sockaddr_in {
      short            sin_family;   // e.g. AF_INET, AF_INET6
      unsigned short   sin_port;     // e.g. htons(3490)
      struct in_addr   sin_addr;     // see struct in_addr, below
      char             sin_zero[8];  // zero this if you want to
  };
  </code></pre>
  
  <p>Here the member <code>sin_addr</code> is of type <code>struct in_addr</code>.</p>
  
  <p>But I don't get why someone would like to do that as all <code>struct inaddr</code> has is : </p>
  
  <pre><code>struct in_addr {
      unsigned long s_addr;          // load with inet_pton()
  };
  </code></pre>
  
  <p>All <code>in_addr</code> has is just one member <code>s_addr</code>. Why cannot we have something like this :</p>
  
  <pre><code>struct sockaddr_in {
      short            sin_family;   // e.g. AF_INET, AF_INET6
      unsigned short   sin_port;     // e.g. htons(3490)
      unsigned long    s_addr ; 
      char             sin_zero[8];  // zero this if you want to
  };
  </code></pre>