IPGlobalProperties.GetUdpIPv6Statistics 方法

定义

提供本地计算机的用户数据报协议/Internet 协议版本 6 (UDP/IPv6) 统计数据。

public:
 abstract System::Net::NetworkInformation::UdpStatistics ^ GetUdpIPv6Statistics();
public abstract System.Net.NetworkInformation.UdpStatistics GetUdpIPv6Statistics ();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.UdpStatistics GetUdpIPv6Statistics ();
abstract member GetUdpIPv6Statistics : unit -> System.Net.NetworkInformation.UdpStatistics
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
abstract member GetUdpIPv6Statistics : unit -> System.Net.NetworkInformation.UdpStatistics
Public MustOverride Function GetUdpIPv6Statistics () As UdpStatistics

返回

一个 UdpStatistics 对象,提供本地计算机的 UDP/IPv6 流量统计数据。

属性

例外

调用 Win32 函数 GetUdpStatistics 失败。

本地计算机运行的操作系统不支持 IPv6。

示例

以下示例显示本地计算机的 UDP/IP 统计信息。

void ShowUdpStatistics( NetworkInterfaceComponent version )
{
   IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties();
   UdpStatistics ^ udpStat = nullptr;
   switch ( version )
   {
      case NetworkInterfaceComponent::IPv4:
         udpStat = properties->GetUdpIPv4Statistics();
         Console::WriteLine( "UDP IPv4 Statistics" );
         break;

      case NetworkInterfaceComponent::IPv6:
         udpStat = properties->GetUdpIPv6Statistics();
         Console::WriteLine( "UDP IPv6 Statistics" );
         break;

      default:
         throw gcnew ArgumentException( "version" );
         break;
   }
   Console::WriteLine( "  Datagrams Received ...................... : {0}", udpStat->DatagramsReceived );
   Console::WriteLine( "  Datagrams Sent .......................... : {0}", udpStat->DatagramsSent );
   Console::WriteLine( "  Incoming Datagrams Discarded ............ : {0}", udpStat->IncomingDatagramsDiscarded );
   Console::WriteLine( "  Incoming Datagrams With Errors .......... : {0}", udpStat->IncomingDatagramsWithErrors );
   Console::WriteLine( "  UDP Listeners ........................... : {0}", udpStat->UdpListeners );
   Console::WriteLine( "" );
}
public static void ShowUdpStatistics(NetworkInterfaceComponent version)
{
    IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
    UdpStatistics udpStat = null;

    switch (version)
    {
        case NetworkInterfaceComponent.IPv4:
            udpStat = properties.GetUdpIPv4Statistics();
            Console.WriteLine("UDP IPv4 Statistics");
            break;
        case NetworkInterfaceComponent.IPv6:
            udpStat = properties.GetUdpIPv6Statistics();
            Console.WriteLine("UDP IPv6 Statistics");
            break;
        default:
            throw new ArgumentException("version");
        //    break;
    }
    Console.WriteLine("  Datagrams Received ...................... : {0}",
        udpStat.DatagramsReceived);
    Console.WriteLine("  Datagrams Sent .......................... : {0}",
        udpStat.DatagramsSent);
    Console.WriteLine("  Incoming Datagrams Discarded ............ : {0}",
        udpStat.IncomingDatagramsDiscarded);
    Console.WriteLine("  Incoming Datagrams With Errors .......... : {0}",
        udpStat.IncomingDatagramsWithErrors);
    Console.WriteLine("  UDP Listeners ........................... : {0}",
        udpStat.UdpListeners);
    Console.WriteLine("");
}

注解

UDP 是一种无连接传输层协议,负责发送和接收数据报。 它在 IETF RFC 768 中定义。

有关可用于应用程序的 UDP 流量统计信息的详细信息,请参阅 UdpStatistics 类文档。 请注意,此方法返回的对象反映了创建对象时的 UdpStatistics 统计信息。 此信息不会动态更新。

适用于