gpt4 book ai didi

java - 如何获取默认网络适配器的主机广播地址? java

转载 作者:行者123 更新时间:2023-11-29 05:09:19 26 4
gpt4 key购买 nike

如何获取 Java 中默认网络适配器的主机广播地址?

最佳答案

试试这个:

Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements())
{
NetworkInterface networkInterface = interfaces.nextElement();
if (networkInterface.isLoopback())
continue; // Do not want to use the loopback interface.
for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses())
{
InetAddress broadcast = interfaceAddress.getBroadcast();
if (broadcast == null)
continue;

// Do something with the address.
}
}

关于java - 如何获取默认网络适配器的主机广播地址? java ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29238644/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com