亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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è)計有所幫助。

相關(guān)文章

最新評論