Java tutorial
import java.net.DatagramPacket; import java.net.DatagramSocket; class DatagramReceiver { private final static int BUFSIZE = 20; public static void main(String args[]) throws Exception { int port = Integer.parseInt(args[0]); DatagramSocket ds = new DatagramSocket(port); byte buffer[] = new byte[BUFSIZE]; while (true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length); ds.receive(dp); System.out.println(new String(dp.getData())); } } }