How a java application running on Windows 7 chooses which network adapter to use

Hi. I am writing an application for a device - tablet - windows 7 is running. The application is written in java. The application should know which network adapter is available (WIFI, 3G, etc.) Is there a Java library similar to the one developed for Android-android.net, android.net.wifi, etc. - In short: How does a java application running on Windows 7 choose which network adapter to use? Thanks!

+4
source share
1 answer

You can see which network interfaces are available using java.net.NetworkInterface.getNetworkInterfaces() . Note. The loopback interface is always on this list.

However, it seems that the only way to force the system to use certain network interfaces is to look at the IP address where the specific network interface is located. For example, the 4-arg Socket constructor accepts a local address as the third argument (I am associated with only one, other accepts the host name as the first argument).

DatagramSocket has a 2-arg constructor that does something similar.

+1
source

All Articles