c# - C#如何检查代理服务器是否工作?
问题描述
请帮助如何检查代理服务器是否正常工作。如果它不起作用,它应该显示一条消息
解决方案
尝试 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();
}
推荐阅读
- python - 返回 False 三次而不是一次
- php - 60 秒后上传文件时出现错误请求 400
- c# - Visual Studio 2019 C# 突出显示不起作用?
- reactjs - 在尝试将图像从 res.data.photo 传递给 useContext 时,我收到无法读取未定义的属性“数据”
- c++ - 在单个容器中管理扩展对象
- php - 目录访问被禁止。Laravel 在 php artisan serve 上显示此消息
- audio - p5 找不到变量 masterVolume
- python - Python 中的决策区域
- pandas - 通过浮动列表标量实现 Pandas 多列
- c - Raylib 未定义对树莓派上的函数的引用