社区
Windows客户端开发
帖子详情
请问 .NET CF2.0中,如何判断当前网络状态
gameboy766
2007-05-14 03:05:59
开发环境是VS2005,需求是实时的显示和某服务器(固定)之间的大致网络状态,至少要知道通还是不同,能精确反映更好。
麻烦知道的大侠发段源码(C#、vb均可)或发有源码的网址也行,先谢了。
...全文
351
3
打赏
收藏
请问 .NET CF2.0中,如何判断当前网络状态
开发环境是VS2005,需求是实时的显示和某服务器(固定)之间的大致网络状态,至少要知道通还是不同,能精确反映更好。 麻烦知道的大侠发段源码(C#、vb均可)或发有源码的网址也行,先谢了。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
gameboy766
2007-05-17
打赏
举报
回复
谢谢楼上回答,不过这种方法太麻烦了,因为这样还需要在服务器部署一些程序,而且请求这个页面也是需要等待的,特别是网络不通时。
目前自己暂时找到的了一个方法:
string myip = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0].ToString();
如果在网络环境中,那么myip是自动分配的一个局域网ip,否则是127.0.0.1。然后把这句放在一个定时器里面,每隔1秒处理一次,模拟器测试是很成功,立即可知,实际设备还没试过,不知道有没有问题。另外就是这个方法只是保证该移动设备在局域网里面,但没保证和那台服务器联通(但理论上那台服务器肯定在这个局域网里面)。希望高手们提高更好更简便的方案(尽量不在服务器上部署额外程序)。
redfox105
2007-05-16
打赏
举报
回复
在服务器一个页面,定时向服务器请求这个页面就知道网络是否通了
/// <summary>
/// 检查网络是否可以访问
/// </summary>
/// <returns></returns>
public static bool IsWebAccessible()
{
HttpWebRequest request;
HttpWebResponse response;
string Url = Config.Config.AppConfig["TestUrl"].ToString();
bool bConnected = false;
try
{
request = (HttpWebRequest)WebRequest.Create(Url);
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
bConnected = true;
}
response.Close();
}
catch (WebException we)
{
bConnected = false;
EventLog.Write(we);
EventLog.Write(new Exception("无法连接到服务器:" +Url));
}
catch (Exception ex)
{
bConnected = false;
EventLog.Write(ex);
}
finally
{
request = null;
response = null;
}
return bConnected;
}
gameboy766
2007-05-14
打赏
举报
回复
自己顶下
华为荣耀recovery1.0
源码链接: https://pan.quark.cn/s/a4b39357ea24 This directory contains a script ('makefsdata') to create C code suitable for httpd for given html pages (or other files) in a directory. There is also a plain C console application doing the same and extended a bit. Usage: htmlgen [targetdir] [-s] [-i]s targetdir: relative or absolute path to files to convert switch -s: toggle processing of subdirectories (default is on) switch -e: exclude HTTP header from file (header is created at runtime, default is on) switch -11: include HTTP 1.1 header (1.0 is default) if targetdir not specified, makefsdata will attempt to process files in subdirectory 'fs'.
光纤耦合器Matlab模拟.rar
光纤耦合器Matlab模拟.rar
ModbusDoctor软件
官网下载地址:需墙:https://www.kscada.com/modbusdoctor.html 使用非常简单,并且免费、免安装 Modbus Doctor(强烈推荐) 下载地址:搜索 “Modbus Doctor” 官网或 GitHub 界面现代化,支持
中
文,操作和 Modbus Poll 很像
Windows客户端开发
7,655
社区成员
18,839
社区内容
发帖
与我相关
我的任务
Windows客户端开发
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
复制链接
扫一扫
分享
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章