简体   繁体   中英

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 ?

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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