more shit

i should mention im doing live tests before upload, and this is
pre-maintenance, anything worth noting will be written in comments

Signed-off-by: deepCurse <leverplays@gmail.com>
This commit is contained in:
lever1209 2021-12-06 10:58:30 -04:00
commit 1380bc2a22
No known key found for this signature in database
GPG key ID: EEBCBB60C9DFC782
24 changed files with 663 additions and 288 deletions

View file

@ -0,0 +1,38 @@
package pkg.deepCurse.nopalmo.utils;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
import java.util.Date;
public class UptimePing {
public static long sendPing(String IP) throws Exception {
int port = 80;
long timeToRespond = 0;
InetAddress inetAddress = InetAddress.getByName(IP);
InetSocketAddress socketAddress = new InetSocketAddress(inetAddress, port);
SocketChannel sc = SocketChannel.open();
sc.configureBlocking(true);
Date start = new Date();
if (sc.connect(socketAddress)) {
Date stop = new Date();
timeToRespond = (stop.getTime() - start.getTime());
}
// System.out.println("fix me"); // not sure why this is here
if (socketAddress.getAddress() == null) {
return -1;
} else {
return timeToRespond;
}
}
}