C#实现TCP连接信息统计的方法
更新时间:2015年07月03日 10:06:48 作者:程序猴
这篇文章主要介绍了C#实现TCP连接信息统计的方法,可实现有效获取TCP连接信息及连接状态的功能,需要的朋友可以参考下
本文实例讲述了C#实现TCP连接信息统计的方法。分享给大家供大家参考。具体实现方法如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net.NetworkInformation; namespace test2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); TcpConnectionInformation[] connections = properties.GetActiveTcpConnections(); foreach (TcpConnectionInformation t in connections) { listBoxResult.Items.Add("本地端点: " + t.LocalEndPoint.Address); listBoxResult.Items.Add("远程端点: " + t.RemoteEndPoint.Address); listBoxResult.Items.Add("状态:" + t.State); } } } }
希望本文所述对大家的C#程序设计有所帮助。
相关文章
C#中的char、string和StringBuilder的使用详解
这篇文章主要介绍了C#中的char、string和StringBuilder的使用详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-07-07在C# WPF下自定义滚动条ScrollViewer样式的操作
这篇文章主要介绍了在C# WPF下自定义滚动条ScrollViewer样式的操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2021-01-01
最新评论