C#檢測遠程計算機端口是否打開的方法
更新時間:2015年03月23日 09:54:33 作者:chongq
這篇文章主要介紹了C#檢測遠程計算機端口是否打開的方法,實例分析了C#實現(xiàn)檢測遠程端口開啟的技巧,需要的朋友可以參考下
本文實例講述了C#檢測遠程計算機端口是否打開的方法。分享給大家供大家參考。具體分析如下:
這段C#代碼用于檢測遠程計算機的3389端口是否處理打開狀態(tài),可以根據(jù)實際需要設(shè)置其它端口
using System; using System.Collections.Generic; using System.Text; using System.Net.NetworkInformation; namespace test { class Program { static void Main(string[] args) { GetTcpConnections(); } public static void GetTcpConnections() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); TcpConnectionInformation[] connections = properties.GetActiveTcpConnections(); foreach (TcpConnectionInformation t in connections) { Console.Write("Local endpoint: {0} ", t.LocalEndPoint.ToString()); Console.Write("Remote endpoint: {0} ", t.RemoteEndPoint.ToString()); Console.WriteLine("{0}", t.State); } Console.WriteLine(); Console.ReadLine(); } } }
運行結(jié)果如下:
Local endpoint: 127.0.0.1:1025 Remote endpoint: 127.0.0.1:1026 Established Local endpoint: 127.0.0.1:1026 Remote endpoint: 127.0.0.1:1025 Established Local endpoint: 127.0.0.1:1028 Remote endpoint: 127.0.0.1:16992 CloseWait Local endpoint: 127.0.0.1:1110 Remote endpoint: 127.0.0.1:4900 Established Local endpoint: 127.0.0.1:2754 Remote endpoint: 127.0.0.1:1110 CloseWait Local endpoint: 127.0.0.1:2762 Remote endpoint: 127.0.0.1:1110 CloseWait Local endpoint: 127.0.0.1:2773 Remote endpoint: 127.0.0.1:1110 CloseWait Local endpoint: 127.0.0.1:2913 Remote endpoint: 127.0.0.1:1110 CloseWait Local endpoint: 127.0.0.1:3014 Remote endpoint: 127.0.0.1:1110 CloseWait Local endpoint: 127.0.0.1:3531 Remote endpoint: 127.0.0.1:1110 CloseWait Local endpoint: 127.0.0.1:4012 Remote endpoint: 127.0.0.1:1110 CloseWait Local endpoint: 127.0.0.1:4900 Remote endpoint: 127.0.0.1:1110 Established
希望本文所述對大家的C#程序設(shè)計有所幫助。
您可能感興趣的文章:
- c# 防火墻添加/刪除 特定端口的示例
- C#端口轉(zhuǎn)發(fā)用法詳解
- 基于C#實現(xiàn)的端口掃描器實例代碼
- c#檢測端口是否被占用的簡單實例
- C#獲取Windows進程監(jiān)聽的TCP/UDP端口實例
- C#開發(fā)之Socket網(wǎng)絡(luò)編程TCP/IP層次模型、端口及報文等探討
- asp.net(c#)動態(tài)修改webservice的地址和端口(動態(tài)修改配置文件)
- c# 連接字符串?dāng)?shù)據(jù)庫服務(wù)器端口號 .net狀態(tài)服務(wù)器端口號
- c# AcceptEx與完成端口(IOCP)結(jié)合的示例
相關(guān)文章
C#使用Tesseract進行Ocr識別的方法實現(xiàn)
本文主要介紹了C#使用Tesseract進行Ocr識別的方法實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06C#提示:“在證書存儲區(qū)中找不到清單簽名證書”的解決方法
這篇文章主要介紹了C#提示:“在證書存儲區(qū)中找不到清單簽名證書”的解決方法,分析了幾種常見的解決方案供大家選擇使用,具有一定參考借鑒價值,需要的朋友可以參考下2015-01-01DevExpress設(shè)置餅狀圖的Lable位置實例
這篇文章主要介紹了DevExpress設(shè)置餅狀圖的Lable位置的方法,以實例形式詳細講述了設(shè)置餅狀圖的Lable位置具體實現(xiàn)過程,需要的朋友可以參考下2014-10-10c#幾種數(shù)據(jù)庫的大數(shù)據(jù)批量插入(SqlServer、Oracle、SQLite和MySql)
這篇文章主要介紹了c#幾種數(shù)據(jù)庫的大數(shù)據(jù)批量插入(SqlServer、Oracle、SQLite和MySql),需要的朋友可以了解一下。2016-11-11