C#获取网络状态
/// <summary>
/// 获取网络状态
/// </summary>
/// <param name="ip">目标IP地址</param>
/// <returns></returns>
public bool GetNewtWorkStatus(string ip)
{
if (ip == "." || ip == "127.0.0.1" || ip == "localhost")
return NetworkInterface.GetIsNetworkAvailable();
int splitPos = ip.IndexOf('\\');
if (splitPos > 0)
{
ip = ip.Substring(0, splitPos);
}
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
options.DontFragment = true;
string data = "lzltest";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = this.delaytime > 0 ? delaytime : 500;
PingReply reply = pingSender.Send(ip, timeout, buffer, options);
if (reply.Status == IPStatus.Success)
return true;
return false;
}
C#获取网络状态的更多相关文章
- iOS 获取网络状态
在iOS开发者,获取网络状态比较常用 -(NSString *)getNetWorkStates{ UIApplication *app = [UIApplication sharedApplicat ...
- android开发获取网络状态,wifi,wap,2g,3g.工具类(一)
android开发获取网络状态整理: package com.gzcivil.utils; import android.content.Context; import android.net.Con ...
- Android获取网络状态
Android获取网络状态 学习自 https://developer.android.google.cn/reference/android/net/ConnectivityManager http ...
- 微信小程序 --- 获取网络状态
获取网络状态:wx.getNetworkType btnclick:function(){ wx.getNetworkType({ success:function(res){ console.log ...
- React Native之Fetch简单封装、获取网络状态
1.Fetch的使用 fetch的使用非常简单,只需传入请求的url fetch('https://facebook.github.io/react-native/movies.json'); 当然是 ...
- [React Native]获取网络状态
使用React Native,可以使用NetInfo API获取手机当前的各个网络状态. componentWillMount() { NetInfo.fetch().done((status)=&g ...
- Android 通过广播获取网络状态
Android系统网络连接状态的改变会发一个广播,注册一个广播接收者,实时动态的检测网络状态,及时提醒用户,优化用户体验. 本文仅提供WIFI 状态的检测作为参考,其他网络连接方式请 ...
- 5、android ConnectivityManager获取网络状态
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ...
- android 中获取网络状态、判断3G、2G、wifi网络、判断wifi是否打开、获取本机地址、获取本机串号IMEI整理
代码如下:package com.android.xym; import java.io.IOException; import java.net.HttpURLConnection; import ...
随机推荐
- 给virtualbox里linux添加共享文件夹
首先,必须要有已经在VirtualBox中安装好的Ubuntu系统,才能按照以下步骤操作,具体怎样在VirtualBox中安装Ubuntu系统百度经验里已经有很多,大家可以自己查询参照. 打开虚拟 ...
- pOJ-1061 exgcd求同余方程组
链接 就是求(m-n)*a+b*l=y-x, 类似于求解a*x+b*y=c,r=gcd(a,b),当c%r==0时有解,用exgcd求出a*x+b*y=gcd(a,b)的解,然后x*c/gcd(a,b ...
- 【scala】可变参数
Scala允许使用可变的参数列表. 语法 在声明的参数类型后边添加星号(*) 示例 object HelloWorld{ def hello(args:String*): Unit ={ for(ar ...
- 【zzulioj-1676】与同学比身高(综合)
题目链接: http://acm.zzuli.edu.cn/problem.php?id=1676 题目描述 新学年开学了,学校又迎来了一批新同学,已知部分同学之间的身高关系,请列出可推断出的同学之间 ...
- uboot配置过程详解1
x210_sd_config : unconfig @$(MKCONFIG) $(@:_config=) arm s5pc11x x210 samsung s5pc110 @echo "TE ...
- LeetCode OJ:Combination Sum II (组合之和 II)
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...
- L125
The United States Senate (参议院)has taken the first step toward ending President Barack Obama's health ...
- Git常用命令以及用法
一 如何让单个文件回退到指定的版本 1. 进入到文件所在文件目录,或者能找到文件的路径 查看整个目录的修改记录 git log . 2. 回退到指定的版本 git reset f7a22076 ...
- Windows Phone 8 Programming Considerations
OpenGL ES 2.0 Support Marmalade supports the Open GL ES 2.0 Graphics API on Windows Phone 8 using a ...
- Java 对称加密
最近在做一个用户 token 功能,学习了加密相关 AES/DES.RSA 等.其中涉及一个对称和非对称加密问题.对称加密虽然没有非对称加密那样安全性高,但好处是加密速度快,但某些场合还是可以选择使用 ...