Pls help me guys. I end my work for one simple program. I need to check a servers status. I tried to use InetAdress.isReacheble and Socket. But sometimes if server on windows I get a server status false. After reading a lot of information, I realized that this is one of the bug of java enter link description here. But the sources are old. Is this problem still relevant? I tried using code this comment enter link description here
private static boolean isReachable(String addr, int openPort, int timeOutMillis) {
try {
// Any Open port on other machine
// openPort = 22 - ssh, 80 or 443 - webserver, 25 - mailserver etc.
try (Socket soc = new Socket()) {
soc.connect(new InetSocketAddress(addr, openPort), timeOutMillis);
}
return true;
} catch (IOException ex) {
return false;
}
If server on Windows I use port RDP (3389). But the customer does not like. He wants me to check the status through ICMP. Is this possible? I found the app ICMP enter link description here. Tried to connect from the application library but nothing happened. I will be grateful for any information!