Android如何测试网络连通性(系统级)
这与 Java 级别的代码无关。我正在寻找的是 Android 如何测试低级别的连接。
例如,当我们调用 getActiveNetwork() 时,正在调用哪些低级(可能是 C++ 甚至 C)代码,它是如何工作的?它是否 ping 到外部地址(这极不可能,只是猜测)?请尝试具体一点。
谢谢,
This is not about Java level code. What I'm looking for is how Android test the connectivities in low level.
for example, when we call getActiveNetwork(), which low level (maybe C++ or even C) code is being called, and how does it work? does it ping to an external address (which is highly unlikely, just guessing around)? please try to be specific.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要研究用于网络的 TCP/IP 和 OSI 模型。
在这些模型中,网络堆栈中的最低级别负责维护数据链路,我相信这可能超出了操作系统的范围,即它都是在硬件级别完成的。
我假设 Android 操作系统仅请求网络接口来“连接”或“断开”,并且可能为较低的数据链路层提供钩子以在网络状态发生变化时进行调用。
您确实必须考虑“网络连接”的含义。您的意思是能够访问网站还是仅仅网络接口具有数据链接......它们不一定是同一件事。
You need to research TCP/IP and OSI Models for networking.
In these models it is the lowest level in the network stack that is responsible for maintaining the data-link and I believe this possibly outside of the scope of the Operating system i.e. it is all done at hardware level.
I would assume that Android OS merely requests a network interface to 'connect' or 'disconnect' and probably provides hooks for the lower Data Link layer to call should network status change.
You really have to consider what you mean by 'network connectivity'. Do you mean being able to access websites or merely a network interface has a data link... they are not necessarily the same thing.