首页 > 解决方案 > C#如何检查代理服务器是否工作?

问题描述

请帮助如何检查代理服务器是否正常工作。如果它不起作用,它应该显示一条消息

标签: c#webproxyipping

解决方案


尝试 ping 它Ping Class

static void Main(string[] args)
    {
        try
        {
            Ping myPing = new Ping();
            PingReply reply = myPing.Send("IP ADDRESS", 2000);
            if (reply != null)
            {
                Console.WriteLine("Status: " + reply.Status + " \n Time: " + reply.RoundtripTime.ToString() + " \n Address: " + reply.Address);                   
            }
        }
        catch
        {
            Console.WriteLine("ERROR: TIMEOUT");
        }
        Console.ReadKey();
    }

推荐阅读