/* ** Objektorienteeritud programmeerimine - ühenduse avamine. ** ** NB! Tegemist on õppeotstarbelise näitega, mis ei ole ** mõeldud reaalses elus kasutamiseks. ** ** @author Gunnar Kudrjavets [gk@aprote.ee] ** @version 0.1, 13.04.1999 ** @since JDK 1.0 */ import java.io.*; import java.net.*; class SimpleSocket { public static void main(String[] args) { try { //Socket s = new Socket("193.40.5.94", 80); // Sama, mis eelmine rida. Socket s = new Socket("www.ut.ee", 80); // Genereerib 'UnknownHostException'-i // Socket s = new Socket("nonexisting.host.com", 80); // Genereerib 'IOException'-i // Socket s = new Socket("www.ut.ee", 1234); System.out.println("Socket created - OK"); // sulgeme pistiku s.close(); } catch (UnknownHostException e) { System.out.println("Can't find host."); } catch (IOException e) { System.out.println("Can't connect to host."); } } }