IPGlobalProperties.GetActiveTcpListeners 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回有关本地计算机上的 Internet 协议版本 4 (IPv4) 和 IPv6 传输控制协议 (TCP) 侦听器的终结点信息。
public:
abstract cli::array <System::Net::IPEndPoint ^> ^ GetActiveTcpListeners();
public abstract System.Net.IPEndPoint[] GetActiveTcpListeners ();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.IPEndPoint[] GetActiveTcpListeners ();
abstract member GetActiveTcpListeners : unit -> System.Net.IPEndPoint[]
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
abstract member GetActiveTcpListeners : unit -> System.Net.IPEndPoint[]
Public MustOverride Function GetActiveTcpListeners () As IPEndPoint()
返回
一个 IPEndPoint 数组,其中包含描述活动 TCP 侦听器的对象;如果没有检测到活动 TCP 侦听器,则为一个空数组。
- 属性
例外
Win32 函数 GetTcpTable
失败。
示例
下面的代码示例显示活动 TCP 侦听器的终结点信息。
void ShowActiveTcpListeners()
{
Console::WriteLine( "Active TCP Listeners" );
IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties();
array<IPEndPoint^>^endPoints = properties->GetActiveTcpListeners();
System::Collections::IEnumerator^ myEnum7 = endPoints->GetEnumerator();
while ( myEnum7->MoveNext() )
{
IPEndPoint^ e = safe_cast<IPEndPoint^>(myEnum7->Current);
Console::WriteLine( e );
}
}
public static void ShowActiveTcpListeners()
{
Console.WriteLine("Active TCP Listeners");
IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] endPoints = properties.GetActiveTcpListeners();
foreach (IPEndPoint e in endPoints)
{
Console.WriteLine(e.ToString());
}
}
注解
此方法返回的对象包括除 状态之外的所有 TCP 状态中的 Listen 侦听器。
TCP 协议在 IETF RFC 793 中定义。 请注意,此方法返回的对象反映创建数组时的连接。 此信息不会动态更新。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈