title: What would be the disadvantages/risks of using AF_UNSPEC?
body: <p>From <a href="https://beej.us/guide/bgnet/html/single/bgnet.html#structs" rel="nofollow noreferrer">Beej's Guide to Network programming</a></p>
  
  <blockquote>
    <p>You can force it to use IPv4 or IPv6 in the ai_family field, or leave it as AF_UNSPEC to use whatever. This is cool because your code can be IP version-agnostic.</p>
  </blockquote>
  
  <p>As the title says - what would be the disadvantages (or risks, if any) of always using <code>AF_UNSPEC</code>, instead of specifying IPv4 or IPv6?</p>
  
  <p>Or it's only for one reason - if the version is specified, this will guarantee that this and only this version is supported?</p>
  
  <hr>
  
  <p>A little background - I think about adding support for IPv6 in client-server (C++) applications and both versions should be supported. So I wondered if it's fine to use <code>AF_UNSPEC</code> or it's better to "recognize" the address from the string and use <code>AF_INET6</code> or <code>AF_INET</code>, depending on the address.</p>