简体   繁体   中英

How determine which netw. Interface is used with java

I want to know if it's possible to determine which network interface is used by a java code.

For example I could use an inputstream with an URL object to download the source code. But I want the traffic to go through the interface wlan0 for example and not eth0. Is it possible to check which interface is currently used for the java network process?

To check with interface was used you can take a tcpdump of all the network traffic in and out of the machine and use a tool like wireshark to view it. A simpler approach is to look at the number of Tx and Rx packets in ifconfig -a to see which interface was used.

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