【发布时间】:2017-04-12 16:12:28
【问题描述】:
我正在编写一个 java 程序来获取我网络中的所有 IP 地址
使用此代码一切正常
InetAddress localhost = InetAddress.getLocalHost();
byte[] ip = localhost.getAddress();
for (int i = 1; i <= 254; i++)
{
ip[3] = (byte)i;
InetAddress address = InetAddress.getByAddress(ip);
if(address.isReachable(1000))
{
System.out.println(address);
}
}
这段代码可以很好地打印 IP 地址。
问题是我想捕获从每个 IP 地址发送和接收的数据包,但我不知道该怎么做
这可能吗?以及如何?
【问题讨论】:
-
好的,谢谢兄弟。
标签: java network-programming inetaddress