zoukankan      html  css  js  c++  java
  • C# Ping Ip 网络是否畅通实现

    最近项目中需要实现 类 cmd 命令ping 的操作。查看当前Ip是否畅通。代码如下:

    第一步 引用:System.Net

    代码如下:

    protected bool Ping(string ip)
         {  
             Ping p = new System.Net.NetworkInformation.Ping();  
             PingOptions options = new PingOptions();  
             options.DontFragment = true;  
             string data = "Test Data!";  
             byte[] buffer = Encoding.ASCII.GetBytes(data);  
             int timeout = 1000;   
             PingReply reply = p.Send(ip, timeout, buffer, options);  
             if (reply.Status == IPStatus.Success)  
                 return true;  
             else  
                 return false;  
         }
  • 相关阅读:
    Node.js Express框架
    Node.js Web模块
    Node.js 工具模块
    Node.js GET/POST请求
    Node.js 文件系统
    Node.js 常用工具
    【day03】Xhtml
    【day02】Xhtml
    【紫书】【重要】Not so Mobile UVA
    【紫书】Tree UVA
  • 原文地址:https://www.cnblogs.com/BungeeJumping/p/5556761.html
Copyright © 2011-2022 走看看