【发布时间】:2012-09-26 00:28:54
【问题描述】:
我想从我的子网扫描 IP 范围。 我想保存将在特定端口上听到的 IP 地址。我使用此代码:
for (int host = 1; host < 255; host++) {
String ip = networkAddress + host;
Socket socket;
try {
socket = new Socket(ip, port);
System.out.println(ip + " +");
serverList.add(ip);
socket.close();
}
catch (Exception e) {
System.out.println(ip + " -");
}
}
但我的问题是它需要太多时间...... 有没有更快的方法?
【问题讨论】:
标签: java sockets local-network port-scanning