博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PING检查网络是否畅通
阅读量:4309 次
发布时间:2019-06-06

本文共 931 字,大约阅读时间需要 3 分钟。

可用于检测网络畅通情况

 

using System.Net;using System.Net.NetworkInformation; namespace PING{    class Program    {        static void Main(string[] args)        {            Console.WriteLine("请输入IP");            string str = Console.ReadLine();             Console.WriteLine(ping(str));            Console.ReadLine();        }        public  static bool ping(string ip)        {            Ping pingip = new Ping();            PingOptions options = new PingOptions();            options.DontFragment = true;            string data = "Test Data";             byte[] bytes = Encoding.ASCII.GetBytes(data);            int timeout = 1000;            PingReply replay = pingip.Send(ip, timeout, bytes, options);            if(replay.Status==IPStatus.Success)            {                return true;            }            else            {                return false;            }        }    }}

 

转载于:https://www.cnblogs.com/wrjy/p/6669344.html

你可能感兴趣的文章
15 可视化工具 Navicat的简单使用
查看>>
神兵利器:Burpsuite工具分享与使用简介
查看>>
xml
查看>>
使用 Left Join 的一个错误说明
查看>>
[Java] Oracle的JDBC驱动的版本说明
查看>>
ASP.NET内置对象之Request对象
查看>>
Spring学习笔记5——注解方式AOP
查看>>
Scala入门系列(十一):模式匹配
查看>>
Sql Server 生成数据透视表 (行列转换等经典SQL语句)
查看>>
理解sizeof()
查看>>
Vue学习笔记之vue-cli脚手架安装和webpack-simple模板项目生成
查看>>
SqlServer 扩展属性
查看>>
优先队列
查看>>
String的Intern方法
查看>>
KRPANO资源分析工具下载720YUN全景图
查看>>
一些程序和工具
查看>>
java8 运算语法集
查看>>
IDEA关于重命名
查看>>
Es6 中let var和 const 了解
查看>>
巧用队列之”Voting“
查看>>