port-scanning

Fastest way to scan ports with Java

陌路散爱 提交于 2019-11-26 17:57:59
问题 I made a very simple port scanner, but it runs too slow, so I'm looking for a way to make it scan faster. Here is my code: public boolean portIsOpen(String ip, int port, int timeout) { try { Socket socket = new Socket(); socket.connect(new InetSocketAddress(ip, port), timeout); socket.close(); return true; } catch (Exception ex) { return false; } } This code tests if a specific port is open on a specific ip. For timeout I used a minimum value of 200 because when I go lower it doesn't have