0

I need multiple UDP servers, using the UDPClient class from .net. For IPv4 i can achieve this by doing the following:

var udpServer1 = new UdpClient(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 53));
var udpServer2 = new UdpClient(new IPEndPoint(IPAddress.Parse("127.0.0.2"), 53));
var udpServer3 = new UdpClient(new IPEndPoint(IPAddress.Parse("127.0.0.3"), 53));

And it works, i can listen on all 3 addresses on port 53. I need to do the same for IPv6. But it seems that i can listen on only 1 loopback address "::1".

If i try to use "::2" i get a "The requested address is not valid in its context" error. Any help would be appreciated.

Thanks!

  • 1
    Unlike IPv4, which has a block of loopback addresses, IPv6 only has a single loopback address. You are going to need to rethink how your application works for IPv6. – Ron Maupin May 04 '17 at 14:53
  • 1
    Some links about this: https://serverfault.com/questions/729856/why-only-a-single-loopback-address-on-ipv6, https://serverfault.com/questions/193377/ipv6-loopback-addresses-equivalent-to-127-x-x-x – xanatos May 22 '17 at 09:24

1 Answers1

0

So, after some more investigation i found out that indeed, IPv6 has only 1 loopback address: "::1".

BUT! There is a little thing called a "link-local" address, that starts with "fe80:..." and you have 1 of those unique to each of your network adapters, that represents the loopback address for that specific network adapter.

So, i can open a server on ::1 port 53, or i can open multiple servers, one for each of the network adapters i do have.