IPGlobalProperties.GetUdpIPv6Statistics 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供本機電腦的使用者資料包通訊協定/網際網路通訊協定第 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 統計數據。 此資訊不會動態更新。