CrazyEngineers
  • need code for multicasting in java

    umaragavan21

    umaragavan21

    @umaragavan21-Fy1jWo
    Updated: Oct 26, 2024
    Views: 1.3K
    multicasting in java, which contains a single administrator and and a single leader for each sub group
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    Please explain the problem fully. Multicasting, you say, but its actually Typecasting...
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 15, 2011

    [​IMG]
    i have to implement this model
    which has one administrator for the whole group and sub group leader for each subgroup.The administrator sends a message to each sub group leader and the subgroup leaders send that message to their group members.
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    Unable to open the image or the link you have specified man!
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 15, 2011

    #-Link-Snipped-#
    please have a look at this link. The paper is PLEASE, ‘P’-LEAder SElection for Multicast Group Communication
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    Sure... 😀 Will help ya out!!! 😀
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 15, 2011

    thank u so much
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    Hey, this is Multicast Networking... You heard of broadcast and telecast right? The same way this works. And for Java, what are you trying to do, the same project or you have any other idea? Like sending a bulk SMS to many? 😉
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    Check this out... For developers they have given a tutorial on how to multicast using Java... 😀
    #-Link-Snipped-# 😀
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 15, 2011

    i m going to implement the same project
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 15, 2011

    this code is not working
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    Can you post the code?
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 15, 2011

    import java.io.*;
    import java.net.*;
    import java.util.*;

    public class MulticastClient {

    public static void main(String[] args) throws IOException {

    MulticastSocket socket = new MulticastSocket(4446);
    InetAddress address = InetAddress.getByName("230.0.0.1");
    socket.joinGroup(address);

    DatagramPacket packet;

    // get a few quotes
    for (int i = 0; i < 5; i++) {

    byte[] buf = new byte[256];
    packet = new DatagramPacket(buf, buf.length);
    socket.receive(packet);

    String received = new String(packet.getData(), 0, packet.getLength());
    System.out.println("Quote of the Moment: " + received);
    }

    socket.leaveGroup(address);
    socket.close();
    }

    }
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 15, 2011

    import java.io.*;
    import java.net.*;
    import java.util.*;

    public class MulticastServerThread extends QuoteServerThread {

    private long FIVE_SECONDS = 5000;

    public MulticastServerThread() throws IOException {
    super("MulticastServerThread");
    }

    public void run() {
    while (moreQuotes) {
    try {
    byte[] buf = new byte[256];

    // construct quote
    String dString = null;
    if (in == null)
    dString = new Date().toString();
    else
    dString = getNextQuote();
    buf = dString.getBytes();

    // send it
    InetAddress group = InetAddress.getByName("230.0.0.1");
    DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446);
    socket.send(packet);

    // sleep for a while
    try {
    sleep((long)(Math.random() * FIVE_SECONDS));
    } catch (InterruptedException e) { }
    } catch (IOException e) {
    e.printStackTrace();
    moreQuotes = false;
    }
    }
    socket.close();
    }
    }
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 15, 2011

    public class MulticastServer {
    public static void main(String[] args) throws java.io.IOException {
    new MulticastServerThread().start();
    }
    }
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    Error log please...
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    Did you include the MulticastServer class first???
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 16, 2011

    ya i included.
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 16, 2011

    Oki, send the error log here... Please wrap it up in code tags... 😀
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 16, 2011

    praveenscience
    Oki, send the error log here... Please wrap it up in code tags... 😀[/QUOTE
    i getting error in MulticastServer
    " cant find symbol public class MulticastServerThread extends QuoteServerThread"'
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 16, 2011

    Dude, that's what I said, you haven't included the class MulticastServerThread correctly!!! Include it and it works... 😀
    Are you sure? This action cannot be undone.
    Cancel
  • umaragavan21

    MemberMay 16, 2011

    ya now it works without error but when i run MulticastServer i am getting an error couldnot open quote file.Serving time instead
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 16, 2011

    Woah.. Congrats,., 😀
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register