3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by mahdi68
0

You can try to ping well know IP like google servers and see if you get response

how con i do this ???

0

Hi , i use this code for check connection but it`s work fine only in root user !!!

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;


public class Connection {

	/**
	 * @param args
	 */
	public static boolean status;
	public static void main(String[] args) {
		String host = "209.85.229.147";
        int timeout = 3000;
        try {
			status = InetAddress.getByName(host).isReachable(timeout);
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (status) {
            System.out.println("Online");
        } else {
            System.out.println("Offline");
        }


	}

}

how can i do it for normal user`s ???
thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.