/** * Fail Dserver.java * @author Jaanus Poial * @version 0.1 kevad 99 */ import java.net.*; import java.io.*; import java.util.Date; public class Dserver { public static void main (String [] parameetrid) { int pordinumber; // UDP-pordi number if (parameetrid.length == 0) pordinumber = 5678; else pordinumber = Integer.parseInt (parameetrid [0]); try { DatagramSocket dpistik = new DatagramSocket (pordinumber); // analoog serverpistikuga -- istume ja kuulame while (true) { // lopmatu tsu"kkel, ctrl-c abil va"lja byte [] andmed = new byte [1024]; DatagramPacket pakett = new DatagramPacket (andmed, andmed.length); dpistik.receive (pakett); String teade = new String (pakett.getData(), 0, pakett.getLength()); InetAddress aadress = pakett.getAddress(); System.out.println ("\nSaabus " + aadress.toString() + " " + new Date().toString() + ":\n" + teade); } } catch (IOException e) { System.out.println (e); } } // main lopp } // Dserver lopp