今天早上我在做一个项目,遇到了一个有趣的问题。我注意到有时 NetworkInterface.NetworkInterfaceType
包含一个不在记录的枚举列表中的值,特别是值“53”。这个接口(interface)是一个 OpenVPN 连接,我已经能够解决它,但它确实令人困惑。有没有其他人遇到过这个问题?
private static void GetEndpoints()
{
List<IPAddress> AddressList = new List<IPAddress>();
NetworkInterface[] Interfaces = NetworkInterface.GetAllNetworkInterfaces();
string Msg = String.Empty;
foreach(NetworkInterface I in Interfaces)
{
Msg += String.Format("{0} ({1}) - {2}\r\n",
I.Name,
I.GetIPProperties()
.UnicastAddresses
.Where(x => x.Address.AddressFamily == AddressFamily.InterNetwork)
.FirstOrDefault()
?.Address,
I.NetworkInterfaceType);
}
MessageBox.Show(Msg);
}
最佳答案
跟踪对 GetAdaptersInfo
的实际调用和结果 PIP_ADAPTER_INFO
,您可以从 this source, 查看 Ipifcons.h
中定义的类型它是一个虚拟的。
关于c# - 什么是网络接口(interface)类型 53?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58821325/