Вопрос

I got this error when I tried to parse an IP address that was in string form.

I was using a public dns ip address (4.2.2.2) while testing this (using the System.Net's IPAddress.Parse method).

It does the parsing correctly and returns an IPAddress object. However, if I try to access the ScopeId property of this object, a SocketException is thrown with the message given in the title.

I really am not able to figure out whats the problem here. When I checked the documentation of IPAddress.ScopeId property, it says an exception is thrown when AddressFamily=InterNetwork which is the case with my example.

Could someone please explain the reason for this.

Это было полезно?

Решение

ScopeID is an IPv6 specific field. You have an IPv4 address. Therefore, an exception is raised. InterNetwork in this case means IPv4.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top