C#實(shí)現(xiàn)TCP連接信息統(tǒng)計(jì)的方法
更新時間:2015年07月03日 10:06:48 作者:程序猴
這篇文章主要介紹了C#實(shí)現(xiàn)TCP連接信息統(tǒng)計(jì)的方法,可實(shí)現(xiàn)有效獲取TCP連接信息及連接狀態(tài)的功能,需要的朋友可以參考下
本文實(shí)例講述了C#實(shí)現(xiàn)TCP連接信息統(tǒng)計(jì)的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
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("本地端點(diǎn): " + t.LocalEndPoint.Address);
listBoxResult.Items.Add("遠(yuǎn)程端點(diǎn): " + t.RemoteEndPoint.Address);
listBoxResult.Items.Add("狀態(tài):" + t.State);
}
}
}
}
希望本文所述對大家的C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
C# 實(shí)現(xiàn)簡易的串口監(jiān)視上位機(jī)功能附源碼下載
這篇文章主要介紹了C# 實(shí)現(xiàn)簡易的串口監(jiān)視上位機(jī)功能,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-11-11
DevExpress實(shí)現(xiàn)TreeList節(jié)點(diǎn)互斥的方法
這篇文章主要介紹了DevExpress實(shí)現(xiàn)TreeList節(jié)點(diǎn)互斥的方法,對于初學(xué)者更好的理解C#有一定的幫助,需要的朋友可以參考下2014-08-08
C# 文件下載之?dāng)帱c(diǎn)續(xù)傳實(shí)現(xiàn)代碼
本篇文章主要介紹了C# 文件下載之?dāng)帱c(diǎn)續(xù)傳實(shí)現(xiàn)代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-01-01
C#實(shí)現(xiàn)讓窗體永遠(yuǎn)在窗體最前面顯示的實(shí)例
這篇文章主要介紹了C#實(shí)現(xiàn)讓窗體永遠(yuǎn)在窗體最前面顯示,功能非常實(shí)用,需要的朋友可以參考下2014-07-07
解決C#中取消方向鍵對控件焦點(diǎn)控制的實(shí)現(xiàn)方法
本篇文章是對C#中取消方向鍵對控件焦點(diǎn)控制的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05

