什么是检测到使用.NET连接到Internet的最佳方法是什么? [英] What's the best way to detect an internet connection using .NET?

查看:110
本文介绍了什么是检测到使用.NET连接到Internet的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体应用程序。当用户进口许可证为我的应用程序,我想打电话回家(打在网络上一个aspx页)和注册许可信息。

I have a Windows Forms application. When the user imports a license for my application I'd like to "phone home" (hit an aspx page on the web) and register the license information.

的问题是,用户可能不具有互联网连接的那一刻的工作。我想对此进行测试。什么是检测用户是否有互联网连接可用的最佳方法是什么?

The problem is that the user may not have an internet connection working at that moment. I'd like to test this first. What's the best way to detect if the user has an internet connection available?

推荐答案

在一个PPOE,至少十万美元花在了这个问题。主要症结点:

At a PPOE, at least a hundred thousand dollars was spent on this question. The main sticking points:

  1. 很多时候,HTTP连接将走出去,回来了200 OK的消息。只有它不是你的网站;它的酒店/咖啡厅/无论路由器产品来连接你。

  1. A lot of the time, an HTTP connection will go out, and come back with a "200 OK" message. Only it's not your site; it the hotel/cafe/whatever router offering to connect you.

这些API将在于有趣和创造性的方式。例如,某些Windows网络的API返回接触不良数据如果您曾经有一个调制解调器,但后来升级为DSL,但没有运行该向导。

The APIs will lie in interesting and creative ways. For example, some of the Windows network APIs return bad connection data if you used to have a modem, but then upgraded to DSL, but didn't run the wizard.

在某些(非常重要)的地方,尝试连接将启动一个连接 - 在拨号 - 一个每分钟收费。再次,在PPOE他们运的软件,这样做的凌晨3:00相当流行位。取得了一些严重脾气暴躁的客户。

In some (very important) places, trying to connect will start a connection -- on dialup -- with a per-minute charge. Again, at the PPOE they shipped a reasonably popular bit of software that did this at 3:00 AM. Made for some seriously grumpy customers.

一些主要的互联网服务供应商对宽带上运行时,他们没有足够的聪明,只用最好的以太网和TCP / IP给他们独一无二的软件。相反,他们使用以太网模拟调制解调器(这又是设置到仿真以太网+ TCP / IP设置)。这就是所谓的PPPOE,这使得它很难告诉你要使用什么样的适配器

Some major ISPs have "unique" software when run on broadband where they weren't clever enough to just use the nice Ethernet and TCP/IP they are given. Instead they use the Ethernet to emulate a modem (which in turn is set up to emulate an Ethernet +tcp/ip setup). It's called PPPOE and it makes it hard to tell what adapter you are trying to use

,越来越多的家庭都使用DSL和其中所述计算机被连接卡贝尔调制解调器,但只对本地箱;当地盒子可能已经失去了连接,你不会知道的。

More and more homes are using DSL and Cabel modems where the computer is "connected", but only to the local box; the local box may have lost connectivity and you won't ever know.

唯一的办法就是尝试连接并验证了回报。

THE ONLY SOLUTION is to try a connection AND validate the return.

这篇关于什么是检测到使用.NET连接到Internet的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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