Upraviť

Zdieľať cez


IPAddress.MapToIPv4 Method

Definition

Maps the IPAddress object to an IPv4 address.

public:
 System::Net::IPAddress ^ MapToIPv4();
public System.Net.IPAddress MapToIPv4 ();
member this.MapToIPv4 : unit -> System.Net.IPAddress
Public Function MapToIPv4 () As IPAddress

Returns

Returns IPAddress.

An IPv4 address.

Remarks

Dual-stack sockets always require IPv6 addresses. The ability to interact with an IPv4 address requires the use of the IPv4-mapped IPv6 address format. Any IPv4 addresses must be represented in the IPv4-mapped IPv6 address format which enables an IPv6 only application to communicate with an IPv4 node. The IPv4-mapped IPv6 address format allows the IPv4 address of an IPv4 node to be represented as an IPv6 address. The IPv4 address is encoded into the low-order 32 bits of the IPv6 address, and the high-order 96 bits hold the fixed prefix 0:0:0:0:0:FFFF. The IPv4-mapped IPv6 address format is specified in RFC 4291. For more information, see www.ietf.org/rfc/rfc4291.txt.

If you want to use MapToIPv4 to convert an IPv4 address from IPv6 format to IPv4 format, you must first ensure that you've got an IPv4 address. Call IsIPv4MappedToIPv6, which will return true if the IP address is originally IPv4 written as IPv6, or false otherwise. If IsIPv4MappedToIPv6 returns true, use MapToIPv4 to make the conversion.

Applies to