C#实现TCP连接信息统计的方法

作者:程序猴 时间:2022-12-04 16:31:46 

本文实例讲述了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#,TCP
0
投稿

猜你喜欢

  • Java Spring AOP之PointCut案例详解

    2023-05-24 16:46:15
  • SpringBoot集成Tomcat服务架构配置

    2022-06-30 09:10:11
  • IDEA中设置代码自动提示为Alt+/的具体做法

    2022-07-06 14:58:32
  • Java将Date日期类型字段转换成json字符串的方法

    2023-02-18 19:57:09
  • Android实现波浪球效果

    2021-09-02 16:07:53
  • SQL语句删除和添加外键、主键的方法

    2023-04-16 22:18:35
  • Android 弹出软键盘所遇到的坑及解决方法

    2022-06-03 23:41:47
  • Android实现自定义带文字和图片Button的方法

    2021-06-20 17:13:50
  • jdk15的安装与配置全过程记录

    2023-01-06 05:45:10
  • java用类加载器的5种方式读取.properties文件

    2022-05-06 14:55:19
  • Android超实用的Toast提示框优化分享

    2022-12-20 08:36:32
  • 解决WPF附加属性的Set函数不调用的问题

    2022-09-27 09:52:38
  • Android自定义流式布局的实现示例

    2022-10-14 23:30:44
  • C#实现单例模式的几种方法总结

    2023-10-13 16:33:55
  • Spring JPA之find拓展方法示例详解

    2021-12-11 03:50:49
  • 详解Android Studio 3.0的新特性与适配

    2023-04-29 05:15:05
  • Spring Cloud Ribbon的踩坑记录与原理详析

    2023-02-06 04:06:55
  • Javaweb会话跟踪技术Cookie和Session的具体使用

    2022-06-24 21:16:33
  • Java语言实现数据结构栈代码详解

    2021-12-09 16:15:05
  • Java中的synchronized关键字

    2023-07-28 18:39:26
  • asp之家 软件编程 m.aspxhome.com