Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package OraclePinger;
- import java.net.InetSocketAddress;
- import java.nio.channels.SocketChannel;
- // Representation of a ping target
- //
- public class Target {
- InetSocketAddress address;
- SocketChannel channel;
- Exception failure;
- long connectStart;
- long connectFinish = 0;
- public boolean resolved = false;
- // public boolean timedout = false;
- public Target(String host, int port) {
- try { //resolve host address
- address = new InetSocketAddress(host, port);
- resolved = true;
- } catch (Exception x) {
- failure = x;
- }
- }
- // public void timedout() {
- // if (resolved && connectFinish == 0)
- // timedout = true;
- // }
- public long time(){
- if(!resolved) //flat graph
- return 0;
- if(resolved && connectFinish==0 /*timedout*/) // packet lost / etc over max time. /in nanosecs
- return -1;
- return connectFinish-connectStart;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement