Programmatically choosing the Internet connection (WiFi, mobile broadband,...)

1.6k views Asked by At

I'm developing an application (.NET, C#) for a tablet to check the various networks available, e.g. WiFi or a mobile broadband connection like 4G or 3G. The application has to execute various tests, which basically involve connecting to a specified URL and logging the amount of data sent and returned plus the time involved.

The tablet is running Windows 8 (not 8.1), I'm developing on a Windows 7 PC using Visual Studio 2013. I've already managed to "discover" the active mobile broadband and WiFi connections.

If there are multiple available connections, e.g. both a 4G mobile broadband connection and a WiFi connection, the app should do the same tests on each. However, I still haven't found how I can specify which connection to use. Is this even possible? (How does the tablet pick which one to use?)

1

There are 1 answers

3
flindeberg On BEST ANSWER

This question Choose one of many Internet connections for an application basically answers the same problem.

You have to set the ServicePoint manually for your HttpWebRequest (which I assume you are using?). It's a bit of a hassle but totally doable. The idea behind using WebClient / HttpWebRequest is that you shouldn't have to worry about interfaces though :)

If you would like some code examples, just comment this answer with what's troubling you.