I want to find the IP address on a server on the local network in a short time. I know the port that the application uses on the server.
I tried this, but its too slow. Even when I know the IP, the respiration is too long (for example, about 4 seconds for each IP). Given this method, it would take minutes to scan the entire subnet from 10.0.0.0 to 10.0.0.255.
String ip = "10.0.0.45"; try { InetAddress ping = InetAddress.getByName(ip); Socket s = new Socket(ping, 32400); System.out.println("Server found on IP: " + ping.getCanonicalHostName()); s.close(); } catch (IOException e) { System.out.println("Nothing"); } }
I could use streams, but that would still be slow. I saw the application detect IP in milliseconds. How do they do it? Java code would be appreciated!
rtc11 source share