I have a problem with InetAddress.getLocalHost().getHostAddress(). It works correctly on most machines, but it fails on one where there are more IP addresses available (in this case "the wrong" address belongs to VMware network adapter). I need the address to put it into a message (which then is used on the server as an address where a response should be sent).
I know that I may use NetworkInterface.getNetworkInterfaces() to get all network interfaces but how I may programatically find the right one which is later visible for the server? In my particular case both clients and the server are located inside the same corporate network.