gpt4 book ai didi

c# - IPAddress.ToString 中的地址后的百分号是什么?

转载 作者:行者123 更新时间:2023-11-30 22:51:55 27 4
gpt4 key购买 nike

在代表 IPv6 地址的 IPAddress 实例上调用 ToString() 方法,我得到了一些地址后带有百分号的文本。这是not documented .什么意思?

返回值如下所示:fe80::1538:3f6c:a202:3af7%3

最佳答案

你的是一个Scoped literal IPv6 address

在维基百科页面中按 % 字符搜索:https://en.wikipedia.org/wiki/IPv6_address

在此处粘贴相关段落:

Scoped literal IPv6 addresses

For addresses with other than global scope (as described below), and in particular for link-local addresses, the choice of the network interface for sending a packet may depend on which zone the address belongs to: the same address may be valid in different zones, and be in use by a different host in each of those zones. Even if a single address is not in use in different zones, the address prefixes for addresses in those zones may still be identical, which makes the operating system unable to select an outgoing interface based on the information in the routing table (which is prefix-based).

In order to resolve the ambiguity in textual addresses, a zone index must be appended to the address, the two separated by a percent sign (%).[10] The syntax of zone indices is an implementation-dependent string, although numeric zone indices must be universally supported as well. The link-local address

fe80::1ff:fe23:4567:890a could be expressed by

fe80::1ff:fe23:4567:890a%eth2 or:

fe80::1ff:fe23:4567:890a%3

关于c# - IPAddress.ToString 中的地址后的百分号是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58751009/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com