Ai
2 Star 0 Fork 0

lemonzhang/控制器软件

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
NetHelper.cs 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
lemonzhang 提交于 2021-05-04 21:29 +08:00 . 控制器软件-方案一
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
namespace ControllerClient
{
class NetHelper
{
public static bool PingIpOrDomainName(string strIpOrDName)
{
try
{
Ping objPingSender = new Ping();
PingOptions objPinOptions = new PingOptions();
objPinOptions.DontFragment = true;
string data = "";
byte[] buffer = Encoding.UTF8.GetBytes(data);
int intTimeout = 1000;
PingReply objPinReply = objPingSender.Send(strIpOrDName, intTimeout, buffer, objPinOptions);
string strInfo = objPinReply.Status.ToString();
if (strInfo == "Success")
{
return true;
}
else
{
return false;
}
}
catch (Exception)
{
return false;
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lemonzhang4/ControllerClient.git
git@gitee.com:lemonzhang4/ControllerClient.git
lemonzhang4
ControllerClient
控制器软件
master

搜索帮助