/* ** Objektorienteeritud programmeerimine - datagrammiserver. ** ** NB! Tegemist on õppeotstarbelise näitega, mis ei ole ** mõeldud reaalses elus kasutamiseks. ** ** @author Gunnar Kudrjavets [gk@aprote.ee] ** @version 0.1, 04.13.1999 ** @since JDK 1.0 */ import java.io.*; import java.net.*; public class Pulse { public static void main(String argv[]) throws IOException { final int iPackSize = 1024; if (argv.length == 1) { DatagramSocket s = new DatagramSocket(Integer.parseInt(argv[0])); while (true) { DatagramPacket packet = new DatagramPacket(new byte[iPackSize], iPackSize); s.receive(packet); String message = new String(packet.getData(), 0, 0, packet.getLength()); System.out.println("Heartbeat from: " + packet.getAddress().getHostName() + " - " + message); } } else { System.out.println("I need only one thing - port number!"); } } }