Java端口扫描程序 [英] Java Port scanner
本文介绍了Java端口扫描程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import java.net.Socket;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
String remote = "69.163.44.171";
int i = 0;
do {
try {
Socket s = new Socket(remote,i);
System.out.println("Server is listening on port " + i+ " of " + remote);
s.close();
} catch (IOException ex) {
System.out.println("Server is not listening on port " + i+ " of " + remote);
}
i++;
} while(i == 55000);
}
输出:
Server is not listening on port 0 of 69.163.44.171
BUILD SUCCESSFUL (total time: 0 seconds)
我使用while循环导致它更快,现在问题为什么它只扫描一个端口?
i use while loop cause it is faster, now to the question why does it only scan one port?
推荐答案
嗯...... 你认为条件的频率是多少(i == 55000)
将 true
?
Well... how often did you think the condition while(i == 55000)
would be true
?
这篇关于Java端口扫描程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文