简体   繁体   English

如何检查PC是否通过路由器/交换机连接到互联网?

[英]How to check if PC is connected to internet via router / switch?

I want to detect whether my application is connected to internet via router / switch. 我想检测我的应用程序是否通过路由器/交换机连接到互联网。 I have a port forwarding code in C#, which I want to run only when the PC is behind a router / switch ? 我在C#中有一个端口转发代码,我想只在PC在路由器/交换机后面时运行?

Please help. 请帮忙。

The physical router you see is a red herring. 你看到的物理路由器是一个红色的鲱鱼。 Even with your 3G modem, there is almost surely a router somewhere upstream that you are connected to. 即使你使用的是3G调制解调器,也几乎可以肯定你所连接的上游某个路由器。 There's probably one in the cell tower. 在细胞塔中可能有一个。

I'd approach this by trying to establish the connection without port forwarding. 我通过尝试建立没有端口转发的连接来解决这个问题。 If that works, we're good. 如果这样做,我们很好。 If that doesn't work, try with the port forwarding code. 如果这不起作用,请尝试使用端口转发代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM