स्थानीय होस्ट नाम को निर्धारित करने के लिए यहां कुछ कोड दिया गया है जो बहु-होम बॉक्स पर काम करना है:InetAddress.isSiteLocalAddress() वास्तव में क्या मतलब है?
/**
* Work out the first local host name by iterating the network interfaces
*
* @return
* @throws SocketException
*/
private String findFirstLocalHostName() throws SocketException {
Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
while (ifaces.hasMoreElements()) {
NetworkInterface iface = ifaces.nextElement();
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress add = addresses.nextElement();
if (!add.isLoopbackAddress() && add.isSiteLocalAddress()) {
return add.getHostName();
}
}
}
throw new RuntimeException("Failed to determine local hostname");
}
क्या कॉल करने के लिए SiteLocalAddress एक बग पेश करता है? मुझे इस विधि के बारे में कोई उपयोगी जानकारी नहीं मिल रही है, लेकिन मुझे एहसास है कि यह केवल आईपी वी 6 से संबंधित है और इसे हटा दिया गया है।
स्पष्टता के लिए, मेरा मतलब यह नहीं था कि विधि अब मान्य किया गया था ... बस की "साइट स्थानीय" प्रति कि http आईपीवी 6 में पता धारणा: //www.ietf .org/rfc/rfc3879.txt – TiGz