确定客户端PC是否具有Internet连接 [英] Determining if a client PC has an Internet connection

查看:96
本文介绍了确定客户端PC是否具有Internet连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在编写一个应用程序,需要知道是否有互联网连接

可用。基本上,我希望有类似于电子邮件客户端的大量内容,应用程序可以在在线中工作。或者

离线模式(它保留了下载信息的缓存,所以它可以工作

,如果需要没有连接)。


基本问题是:它下载信息(RSS feed)来自各种各样的来源。这些中的任何一个(或更多)都可能无法下载,因此只需等待超时就不够了(不容易这样做)b
$ b服务器和客户端没有

连接)。此外,如果它等待(比如30s)发生超时,

这对用户来说会有点烦人。


我''已经考虑过尝试连接到一个稳定的主机(即谷歌),如果

失败,那么假设客户端无法连接到互联网,但

这似乎是
有没有办法可靠地确定客户端的状/>
问候,

悬崖


-

Cliff Wells< cl ****** ******@comcast.net>

Hi,

I''m writing an application that needs to know if an Internet connection
is available. Basically, I want to have something similar to what a lot
of email clients have, where the app can work either in "online" or
"offline" mode (it keeps a cache of downloaded info, so it can work
without a connection if needed).

The basic problem is this: it downloads info (RSS feeds) from a variety
of sources. Any one (or more) of these could conceivably fail to
download, so simply waiting for a timeout isn''t sufficient (not easy to
differentiate between having a bad server and the client not having a
connection). Further, if it waits (say 30s) for the timeout to occur,
this is going to be a bit annoying to the user.

I''ve considered trying to connect to a stable host (i.e. Google) and if
that fails then assume the client can''t connect to the internet, but
this seems like a sub-optimal solution.

Is there any way to reliably determine the state of the client''s
internet connectivity?

Regards,
Cliff

--
Cliff Wells <cl************@comcast.net>

推荐答案

Cliff Wells< cl ********* ***@comcast.net> pisze:
Cliff Wells <cl************@comcast.net> pisze:
我正在编写一个需要知道互联网连接是否可用的应用程序。基本上,我希望有类似于很多电子邮件客户端的东西,应用程序可以在在线工作。或
离线模式(它保留了下载信息的缓存,因此它可以在没有连接的情况下工作
如果需要的话)。

基本问题是:它从各种颜色下载信息(RSS feed)消息来源。其中任何一个(或多个)都可能无法下载,因此仅仅等待超时是不够的(不容易区分出服务器坏了和客户端没有
连接)。此外,如果它等待(比如30s)发生超时,这对用户来说会有点烦人。

我考虑过尝试连接稳定主机(即谷歌)如果失败则假设客户端无法连接到互联网,但这似乎是次优解决方案。

有没有任何方法可靠地确定客户的互联网连接状态?
I''m writing an application that needs to know if an Internet connection
is available. Basically, I want to have something similar to what a lot
of email clients have, where the app can work either in "online" or
"offline" mode (it keeps a cache of downloaded info, so it can work
without a connection if needed).

The basic problem is this: it downloads info (RSS feeds) from a variety
of sources. Any one (or more) of these could conceivably fail to
download, so simply waiting for a timeout isn''t sufficient (not easy to
differentiate between having a bad server and the client not having a
connection). Further, if it waits (say 30s) for the timeout to occur,
this is going to be a bit annoying to the user.

I''ve considered trying to connect to a stable host (i.e. Google) and if
that fails then assume the client can''t connect to the internet, but
this seems like a sub-optimal solution.

Is there any way to reliably determine the state of the client''s
internet connectivity?




不,没有这种方式。您可以尝试连接某些通常

working&可用"主机,但总有一些时期,当

这台主机不可用时(预定的停机时间,停电,你的名字是

吧)。以稳定性最大而闻名的主机是根DNS服务器。


-

Jarek Zgoda
http://jpa.berlios.de/


* Jarek Zgoda( 2004-09-19 10:14 +0200)
* Jarek Zgoda (2004-09-19 10:14 +0200)
Cliff Wells< cl ************ @ comcast.net> pisze:
Cliff Wells <cl************@comcast.net> pisze:
我正在编写一个需要知道互联网连接是否可用的应用程序。基本上,我希望有类似于很多电子邮件客户端的东西,应用程序可以在在线工作。或
离线模式(它保留了下载信息的缓存,因此它可以在没有连接的情况下工作
如果需要的话)。

基本问题是:它从各种颜色下载信息(RSS feed)消息来源。其中任何一个(或多个)都可能无法下载,因此仅仅等待超时是不够的(不容易区分出服务器坏了和客户端没有
连接)。此外,如果它等待(比如30s)发生超时,这对用户来说会有点烦人。

我考虑过尝试连接稳定主机(即谷歌)如果失败则假设客户端无法连接到互联网,但这似乎是次优解决方案。

有没有有没有办法可靠地确定客户的互联网连接状态?
I''m writing an application that needs to know if an Internet connection
is available. Basically, I want to have something similar to what a lot
of email clients have, where the app can work either in "online" or
"offline" mode (it keeps a cache of downloaded info, so it can work
without a connection if needed).

The basic problem is this: it downloads info (RSS feeds) from a variety
of sources. Any one (or more) of these could conceivably fail to
download, so simply waiting for a timeout isn''t sufficient (not easy to
differentiate between having a bad server and the client not having a
connection). Further, if it waits (say 30s) for the timeout to occur,
this is going to be a bit annoying to the user.

I''ve considered trying to connect to a stable host (i.e. Google) and if
that fails then assume the client can''t connect to the internet, but
this seems like a sub-optimal solution.

Is there any way to reliably determine the state of the client''s
internet connectivity?



不,没有这种方式。



No, there''s no such way.




我认为必须(或者至少有一种方法可以使用很多b / b
编码器使用,因为测试你是否在线是非常频繁的< br $>
问题)。


Thorsten



I think there has to be (or at least there is a method that many
coders use because "testing if you''re online" is a very frequent
problem).

Thorsten


Thorsten Kampe< th ****** @ thorstenkampe.de> pisze:
Thorsten Kampe <th******@thorstenkampe.de> pisze:
有没有办法可靠地确定客户的互联网状态连接?
Is there any way to reliably determine the state of the client''s
internet connectivity?



不,没有这样的方式。



No, there''s no such way.



我认为必须有(或者至少有一种方法)许多编码人员使用的原因是测试你是否在线是一个非常频繁的问题。)



I think there has to be (or at least there is a method that many
coders use because "testing if you''re online" is a very frequent
problem).




必须有,但不是。我经常在很多论坛上看到这个问题

单一回答。让我引用ICS常见问题解答:


"""

没有完美的解决方案。为什么?因为互联网只是另一个

网络。您的计算机无法区分LAN和Internet。

它们都是网络。其中一个恰好是非常大的。


互联网与您的本地网络没什么不同。这只是一个问题

的大小。


想想你的问题。 我是否已连接到互联网?。试试

将你的问题改为你真正想问的问题。 我可以将

连接到特定的远程主机吗?有了这样的问题,你可以开始解决这个问题。你怎么知道你是否可以连接到远程主机的
?尝试连接。就那么简单。如果连接

尝试失败,则您与远程主机或

远程主机之间没有路径拒绝连接。


但是,我听到你哭了,我不想让自动拨号弹出。我们如何?b $ b绕过这个?询问用户如何建立连接。我们在其他互联网应用程序中看到了这一切所需的时间。 Outlook Express,WinAmp等

他们询问用户他们有什么样的网络连接。从这个

信息中,应用程序可以做出关于如何将
连接到远程主机的最佳选择。


有没有证明方式。但有些事情可以提供帮助。


WinINet.DLL中有一个InternetGetConnectedState函数,如果检测到与Internet的连接,则
返回true。但是,使用这个功能时你唯一可以肯定的是,

计算机不会开始拨号而不会弹出任何对话框

函数返回true,然后你尝试在

互联网上做任何事情。在某些情况下,虽然

计算机已连接,但该功能可能会返回false。

"""


虽然它仅限Win32。


-

Jarek Zgoda
http://jpa.berlios.de/


这篇关于确定客户端PC是否具有Internet连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆