Here is my code :
URL u = new URL(\"http://www.google.com\"); URLConnection conn = u.openConnection(); conn.setConnectTimeout(3000); conn
Some non-standard implmentation of this method may ignore the specified timeout. See this setConnectTimeout
I found a post that can work around it. Use another thread to query DNS to simulate timeout: http://thushw.blogspot.sg/2009/11/resolving-domain-names-quickly-with.html