IPAddress.MapToIPv4 IPAddress.MapToIPv4 IPAddress.MapToIPv4 IPAddress.MapToIPv4 Method

定义

IPAddress 对象映射到 IPv4 地址。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

返回

返回 IPAddressReturns IPAddress.

IPv4 地址。An IPv4 address.

注解

双协议栈套接字始终需要 IPv6 地址。Dual-stack sockets always require IPv6 addresses. 能够使用 IPv4 地址进行交互需要使用 IPv4 映射的 IPv6 地址格式。The ability to interact with an IPv4 address requires the use of the IPv4-mapped IPv6 address format. 任何 IPv4 地址,必须以启用 IPv6 唯一应用程序与 IPv4 节点进行通信的 IPv4 映射的 IPv6 地址格式表示。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. IPv4 映射的 IPv6 地址格式允许一个 IPv4 节点而无法表示为 IPv6 地址的 IPv4 地址。The IPv4-mapped IPv6 address format allows the IPv4 address of an IPv4 node to be represented as an IPv6 address. IPv4 地址被编码为 IPv6 地址的低阶 32 位和高序位 96 位保留固定的前缀 0:0:0:0:0:FFFF。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. RFC 4291 中指定的 IPv4 映射的 IPv6 地址格式。The IPv4-mapped IPv6 address format is specified in RFC 4291. 有关详细信息,请参阅www.ietf.org/rfc/rfc4291.txtFor more information, see www.ietf.org/rfc/rfc4291.txt.

如果你想要使用MapToIPv4将 IPv4 地址从 IPv6 格式转换为 IPv4 格式,您必须首先确保已获得的 IPv4 地址。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. 调用IsIPv4MappedToIPv6,这将返回true如果 IP 地址最初编写为 IPv6 的 IPv4 或false否则为。Call IsIPv4MappedToIPv6, which will return true if the IP address is originally IPv4 written as IPv6, or false otherwise. 如果IsIPv4MappedToIPv6将返回true,使用MapToIPv4进行转换。If IsIPv4MappedToIPv6 returns true, use MapToIPv4 to make the conversion.

适用于