• C# 检查网络通畅


    public static bool PingServer(string ipOrHostName)
             {
                 try
                 {
                     Ping ping = new Ping();

                     PingOptions pingOptions = new PingOptions();

                     pingOptions.DontFragment = true;

                     string data = "";

                     byte[] buffer = Encoding.UTF8.GetBytes(data);

                     int timeout = 120;

                     PingReply reply = ping.Send(ipOrHostName, timeout, buffer, pingOptions);

                     string result = reply.Status.ToString();

                     if (result == "Success")
                     {
                         return true;
                     }
                     else
                     {
                         return false;
                     }
                 }
                 catch (Exception)
                 {
                     return false;
                 }
             }

    君子性非异也,善假于物也!
  • 相关阅读:
    uft/qtp的参数化
    华为数据之道-读书笔记
    python操作neo4j
    PyPDF2提取pdf中的信息
    时间片轮转算法
    百度地图根据类别不同做不同的标注
    操作系统-考点
    《修改代码的艺术》读书笔记
    【2021.07.06】抗争性人格的自我记录
    【2021.06.16】即将到来的毕业
  • 原文地址:https://www.cnblogs.com/zhaoCat/p/5818999.html
Copyright © 2020-2023  润新知