Update to Finding Your IP v4 Broadcast Address Using Java

My earlier post Finding Your IP v4 Broadcast Address Using Java mentioned that you can set the property java.net.preferIPv4Stack using System.setProperty(). I recently wrote a JUnit test of code that used that approach, which failed. After some investigation I realized that Eclipse's JUnit test runner uses a socket to communicate test results back to Eclipse, and that socket had been opened long before my code was able to set the system property.

So, the basic conclusion is that if you must force the use of the IPv4 stack, do so using the command-line:
-Djava.net.preferIPv4Stack=true

Comments

Popular Posts