Reputation: 3
I have been trying to set up a UDP server using IPv6 that accepts packets from IPv4 and IPv6 clients. I am programming using winsock2 in C++ with Codeblocks in Windows. I have successfully received and bounced back a packet from IPv6 from a friend. I can also receive and bounce back packets from myself through IPv4 when I send to a local address of 10.0.0.90 (static) and 127.0.0.1 (loopback). Obviously, when a friend on a different network tries to send to those local addresses through the internet, no packets are received on my end. Where do I find an IPv4 address so that an IPv4-only client can successfully sendto() to my IPv6 server through the internet?
When I ping myself through getaddrinfo() at 127.0.0.1, the resulting addrinfo struct contains a blank wildcard ipv4 address (0.0.0.0) and no ipv6 addresses.
When I ping myself through my IPv6 address using getaddrinfo(), I get only one ipv6 addrinfo struct with the same IPv6 address and no IPv4 struct.
When I call getaddrinfo() with a NULL value for the destination, I get two addrinfo structs both containing the wildcard values of IPv4 and IPv6 locations.
From this question, I have gathered that to connect to an IPv6 server with an ipv4 client, you use an ipv4 mapped ipv6 address. My problem is that I'm not sure if I even have an ipv4 address anymore. When I go to www.whatismyipaddress.com, I get only an ipv6 public address.
None of these trials provided me with an ipv4 address that I could give to an ipv4-only client and now I'm utterly stuck. I have already dealt with binding to a wildcard IP, and disabling IPV6_V6ONLY. Everything works pretty well, but I have no idea where else left to look for a destination address. Could someone please provide me a hint into the right direction? Thanks!
Upvotes: 0
Views: 529
Reputation: 9978
The destination address is the IPv4 address of your server. With V6ONLY disabled your IPv6 socket can receive IPv4 packets, but your server still needs to have a reachable IPv4 address. Without an IPv4 address IPv4-only clients can't reach you.
IPv4 mapped IPv6 addresses are just to represent IPv4 addresses in IPv6 software. But you still need an IPv4 address.
Upvotes: 1