I am experimenting with IPv6 sockets, particularly the \"dual stack\" capability offered on Windows Vista and later, and apparently on Unix by default. I am finding that wh
IPv4 and IPv6 are two separate protocols. Packets of one protocol cannot be handled using the other protocol. That is why the concept of Dual Stack exists: your system runs both the IPv4 and IPv6 protocol stacks, has both IPv4 and IPv6 addresses, etc.
Operating systems have a trick where you can have an IPv6 socket that listens on all IPv4 and IPv6 addresses. You still need to have both address families on the host, and it only works when you bind to the wildcard address. Once you bind that socket to a fixed address that doesn't work anymore and it will only work for the address that you have bound to.
So if you want to listen on all available addresses then setting IPV6_V6ONLY to 0 and listening on the wildcard address work. The IPv4 clients will be shown as using IPv6 addresses starting with ::ffff: with the last 32 bits containing the IPv4 address.
When you want to bind to specific addresses you will need sockets bound to each of the addresses you want to listen on. Then you need to use i.e. select(...) to monitor those sockets and to respond to those that become active because someone connects to them.