Code example for MulticastSocket

Methods: close, send

0
    public void send() { 
        try { 
            InetAddress ip = InetAddress.getByName(this.host);
            DatagramPacket packet = new DatagramPacket(this.data.getBytes(),
                    this.data.length(), ip, this.port);
            MulticastSocket ms = new MulticastSocket();
            ms.send(packet);
            ms.close();
        } catch (Exception e) {
            e.printStackTrace();
        } 
    } 
 /* 
    public static void main(String[] args) { 
        int port = 1234; 
        String host = "224.0.0.1"; 
        String data = "hello world."; 
        Multicastsender ms = new Multicastsender(data, host, port); 
        ms.send(); 
    } 
    */