How to test if a proxy server is working or not?

前端 未结 4 1899
长情又很酷
长情又很酷 2020-12-31 09:38

I\'ve got a pretty big list with proxy servers and their corresponding ports. How can I check, if they are working or not?

4条回答
  •  攒了一身酷
    2020-12-31 10:13

    Working? Well, you have to use them to see if they are working.

    If you want to see if they are online, I guess ping is a first step.

    There is a Ping class in .NET.

    using System.Net.NetworkInformation;
    
    private static bool CanPing(string address)
    {
        Ping ping = new Ping();
    
        try
        {
            PingReply reply = ping.Send(address, 2000);
            if (reply == null) return false;
    
            return (reply.Status == IPStatus.Success);
        }
        catch (PingException e)
        {
            return false;
        }
    }
    

提交回复
热议问题