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:
parent
573443e4b4
commit
1380bc2a22
24 changed files with 663 additions and 288 deletions
38
src/pkg/deepCurse/nopalmo/utils/UptimePing.java
Normal file
38
src/pkg/deepCurse/nopalmo/utils/UptimePing.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue