如何检查连接的3G网络连接的状态?

编程入门 行业动态 更新时间:2024-10-22 11:22:26
本文介绍了如何检查连接的3G网络连接的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下方式:

public static bool IsNetworkConnected() { ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); IReadOnlyList<ConnectionProfile> connectionProfile = NetworkInformation.GetConnectionProfiles(); if (InternetConnectionProfile == null) return false; else return true; }

这当我在一个典型的方式连接到互联网的正常工作 - 通过LAN电缆或Wi-Fi。当我用我的3G USB调制解调器返回false( InternectConnectionProfile 为空)。这是为什么?我怎样才能解决这个问题?

It works fine when I'm connected to the internet in a typical way - via LAN cable or Wi-Fi. When I'm using my 3G USB modem it returns false (InternectConnectionProfile is null). Why is that? How can I fix it?

推荐答案

您可以考虑在互联网上ping一台服务器。这不是100%的回答你的问题,但可能有助于从不同的角度来看。

You may consider pinging a server on the internet. This is not the 100% answer to your question but may be helpful from a different point of view.

using System.Net; using System.Net.NetworkInformation; using (Ping Packet = new Ping()) { if (Packet.Send(IPAddress.Parse(IP), 1000, new byte[] { 0 }).Status == IPStatus.Success)) { // ... } }

更多推荐

如何检查连接的3G网络连接的状态?

本文发布于:2023-11-11 18:25:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579221.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   网络

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!