UdpStatistics.UdpListeners 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取侦听用户数据报协议 (UDP) 数据报的本地终结点的数量。
public:
abstract property int UdpListeners { int get(); };
public abstract int UdpListeners { get; }
member this.UdpListeners : int
Public MustOverride ReadOnly Property UdpListeners As Integer
属性值
指定正在侦听 UDP 数据报的套接字总数的 Int64 值。
示例
下面的代码示例显示指定 Internet 协议版本的 UDP 统计信息。
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("");
}
注解
可以使用 UdpClient 和 Socket 类创建 UDP 侦听器应用程序。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈