C# Ping Ip 网络是否畅通实现
2016-06-03 16:33
1051 查看
最近项目中需要实现 类 cmd 命令ping 的操作。查看当前Ip是否畅通。代码如下:
第一步 引用:System.Net
代码如下:
第一步 引用: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; }
相关文章推荐
- Android发送post请求的两种写法(okHttp&&httpClient)
- HTTPS部署锦囊
- android开发笔记之网络编程—异步加载(AsyncTask)
- BP神经网络
- BP神经网络
- linux使用tcpdump抓包工具抓取网络数据包,多示例演示
- UNIX网络编程笔记(4)—TCP客户/服务器程序示例
- 使用 Netty 进行 UDP 网络编程
- FCN(全卷积神经网络)
- 网络制式
- WebUtils-网络请求工具类
- 使用httpclient实现上传下载(javaWeb系统数据传输http实现)
- 新手教程之:循环网络和LSTM指南 (A Beginner’s Guide to Recurrent Networks and LSTMs)
- Android apache httpClient
- 报错:The type javax.servlet.http.HttpServletRequest cannot be resolved
- 网络爬虫介绍
- HTTPS对谷歌百度SEO的影响
- TCP中 recv和sendf函数
- iOS笔记—NSURLConnection怎么把http改为https
- Unable to enable crypto on TCP connection make sure the sslcafile or sslcapath option are properly