This Java tip demonstrates a method of receiving a Datagram. This code may be used in implementing a communication between different components in a network.

 try {
        byte[] inbuf = new byte[256];  // default size
        DatagramSocket socket = new DatagramSocket();
        // Wait for packet
        DatagramPacket packet = new DatagramPacket(inbuf, inbuf.length);
        // Data is now in inbuf
        int numBytesReceived = packet.getLength();
    } catch (SocketException e) {
    } catch (IOException e) {