title: Creating a socket for IPv6 and IPv4 with Windows XP support
body: <p>For modern operating systems, dual-stack[1] IPv6 socket does everything.</p>
  <p>However, Windows XP is still used by many people in China, we cannot ignore Windows XP support. Unfortunately Windows XP does not support dual-stack IPv6 socket. [2]</p>
  <p>So my approach is:</p>
  <ol>
  <li>Try to create an IPv6 socket and set it to dual-stack.</li>
  <li>If success, keep using it.</li>
  <li>If failed, close IPv6 socket(if exists) then create an IPv4 socket.</li>
  </ol>
  <p>Am I going the right way? I assume there is no one who uses IPv6-only internet connection with Windows XP.</p>
  <hr />
  <p>[1]: call setsockopt with IPV6_V6ONLY=0.</p>
  <p>[2]: Windows XP with no Service Pack supports no IPv6. Windows XP with Service Pack &gt;=1 supports IPv6 without dual-stack.</p>