title: Is gethostbyname guaranteed to return hostent structures with IPv4 addresses?
body: <p>I cannot use <code>getaddrinfo(...)</code> for resolving hostnames and therefore must stick to <code>gethostbyname(...)</code></p>
  
  <p>Is the <code>gethostbyname(...)</code> function guaranteed to return hostent structures that contain only IPv4 (AF_INET) addresses on success, so that the following code would always lead to an IPv4 address:</p>
  
  <pre><code>int resolve(const char *name, struct in_addr *addr) {
  
      struct hostent *he = gethostbyname(name);
  
      if (!he)
          return 1;
  
      memcpy(addr,he-&gt;h_addr_list[0],4);
  
      return 0;
  }
  </code></pre>