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

public static void senddatagram(InetAddress target, 
      int port, byte[] outbuf, int len) {
      
        try {
            DatagramPacket request = new DatagramPacket(outbuf, 
              len, target, port);
              
            DatagramSocket socket = new DatagramSocket();
            socket.send(request);
        } catch (SocketException e) {
        } catch (IOException e) {
        }
        
    }