IPAddress.MapToIPv4 方法

定義

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 位址都必須以 IPv4 對應的 IPv6 位址格式表示,讓 IPv6 唯一的應用程式可以與 IPv4 節點進行通訊。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 節點的 IPv4 位址以 IPv6 位址表示。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. IPv4 對應的 IPv6 位址格式是在 RFC 4291 中指定。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,如果 IP 位址最初是以 IPv4 撰寫,則會傳回 true,否則會傳回 falseCall 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.

適用於