Search code examples
c#ipv6

An address incompatible with the requested protocol was used?


Here is the Code

Socket socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
socket.Connect("fe80::fc33:41d6:77f4:c8c7", 1000);

when i try and connect with this address i get the "An address incompatible with the requested protocol was used" exception.


Solution

  • IPv6 link-lical addresses are valid on every link, so you need to tell the system which link to use. That is usually done by appending % and the interface id to the address. Using global addresses is usually easier.