C#TCP连接信息统计源码
代码如下,平时上课所记录,转载请注明出处http://www.cnblogs.com/minotmin/
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);
}
}
}
}
posted on 2012-09-24 10:31 程序猴chengxuhou.com 阅读(704) 评论(0) 编辑 收藏 举报