Sometimes 'ping myipadress -t' to keep vpn connection alive doesn't work. Below is Java way.
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class VPNKeepAlive {
public final static int TIMEOUT = 3000;
public final static String URL = "myipaddress"; //ip address or domain name
public static void main(String[] args) {
try {
InetAddress inetAddress = InetAddress.getByName(URL);
while(true) {
if(inetAddress.isReachable(TIMEOUT)) {
Thread.sleep(60000);
}
}
} catch (UnknownHostException e) {
System.err.println(e);
} catch (IOException e) {
System.err.println(e);
} catch (InterruptedException e) {
System.err.println(e);
}
}
}


0 comments:
Post a Comment