Question

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.

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top