import java.net.*;

public class UDPRecv {
	public static void main(String args[]) {
		try {
			DatagramSocket s = new DatagramSocket();
			byte[] b = new byte[1024];
			DatagramPacket p = new DatagramPacket(b, 1024);

			System.out.println("Port: " + s.getLocalPort());

			s.receive(p);

			for (int i = 0; i < p.getLength(); i++)
				System.out.print("" + b[i] + " ");

			System.out.println("\nFrom: " + p.getAddress() + ":" + p.getPort());
		} catch (Exception e) {
			System.out.println("Caught " + e);
		}
	}
}
