C # method for detecting whether a remote computer port is open

Source: Internet
Author: User

The example in this article describes how C # detects whether a remote computer port is open. Share to everyone for your reference. The specific analysis is as follows:

This C # code is used to detect whether port 3389 of the remote computer is processing open, and you can set other ports according to the actual needs

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 ();}}}  

The results of the operation are as follows:

Local endpoint:127.0.0.1:1025 remote endpoint:127.0.0.1:1026 establishedlocal endpoint:127.0.0.1:1026 remote Endpoint : 127.0.0.1:1025 establishedlocal endpoint:127.0.0.1:1028 Remote endpoint:127.0.0.1:16992 CloseWaitLocal endpoint: 127.0.0.1:1110 remote endpoint:127.0.0.1:4900 establishedlocal endpoint:127.0.0.1:2754 remote endpoint: 127.0.0.1:1110 closewaitlocal endpoint:127.0.0.1:2762 Remote endpoint:127.0.0.1:1110 closewaitlocal endpoint: 127.0.0.1:2773 remote endpoint:127.0.0.1:1110 closewaitlocal endpoint:127.0.0.1:2913 remote endpoint:127.0.0.1:1110 closewaitlocal endpoint:127.0.0.1:3014 remote endpoint:127.0.0.1:1110 closewaitlocal endpoint:127.0.0.1:3531 remote endpoint:127.0.0.1:1110 closewaitlocal endpoint:127.0.0.1:4012 Remote endpoint:127.0.0.1:1110 CloseWaitLocal endpoint:127.0.0.1:4900 Remote endpoint:127.0.0.1:1110 established

I hope this article is helpful to everyone's C # programming.

In addition to the Declaration, Running GuestArticles are original, reproduced please link to the form of the address of this article
C # method for detecting whether a remote computer port is open

This address: http://www.paobuke.com/develop/c-develop/pbk23100.html






Related Content C # programming call Cards.dll Implementing a graphical licensing feature example of three C # implementations of array inversion Mode C # Four basic data Types C #,. Three ways to convert a string (string) format to a datetime type in net
C # Read the system font color and size method in C #, ASP. NET Universal Extension Tool class typeparsec# for file read, write, create, copy, move, delete dotnetcharting usage examples in C #

C # method for detecting whether a remote computer port is open

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.