try { Socket s = new Socket("???.???.???.???", 80); System.out.println("Connected!"); } catch (SecurityException e) { System.out.println("SecurityException: could not connect."); }