Check Proxy is good or bad Or working or not RRS feed

  • Question

  • Asalam Alaikum (Greetings)!

    I scrap IPs and ports from a website into ListBox. Now, i want to check is IP and Port is Good or Bad or either its working or not. Kindly help or guide me.

    Thank you,

    Muhammad Naveed Haroon

    Monday, October 29, 2018 3:28 AM


All replies

  • According to https://social.msdn.microsoft.com/Forums/en-US/d6c8b7b0-9b17-412b-a9e4-a5d2f09550ff, in order to check the IP you can use the Ping class, but if you also need the port, then use TcpClient.Connect.

    Monday, October 29, 2018 6:15 AM
  • Hi MuhammadNH,

    Here is a sample code about how to check if a port is available for your reference.

    int port = 10011; //<--- This is your value
    bool isAvailable = true;
     // Evaluate current system tcp connections. This is the same information provided
     // by the netstat command line application, just in .Net strongly-typed object
     // form.  We will look through the list, and if our port we would like to use
     // in our TcpClient is occupied, we will set isAvailable to false.
     IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
     TcpConnectionInformation[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections();
     foreach (TcpConnectionInformation tcpi in tcpConnInfoArray)
       if (tcpi.LocalEndPoint.Port==port)
         isAvailable = false;

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 30, 2018 1:50 AM