need code for multicasting in java

multicasting in java, which contains a single administrator and and a single leader for each sub group

Replies

  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Please explain the problem fully. Multicasting, you say, but its actually Typecasting...
  • umaragavan21
    umaragavan21
    [โ€‹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.
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Unable to open the image or the link you have specified man!
  • umaragavan21
    umaragavan21
    #-Link-Snipped-#
    please have a look at this link. The paper is PLEASE, รข€˜Pรข€™-LEAder SElection for Multicast Group Communication
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Sure... ๐Ÿ˜€ Will help ya out!!! ๐Ÿ˜€
  • umaragavan21
    umaragavan21
    thank u so much
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    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? ๐Ÿ˜‰
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Check this out... For developers they have given a tutorial on how to multicast using Java... ๐Ÿ˜€
    #-Link-Snipped-# ๐Ÿ˜€
  • umaragavan21
    umaragavan21
    i m going to implement the same project
  • umaragavan21
    umaragavan21
    this code is not working
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Can you post the code?
  • umaragavan21
    umaragavan21
    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();
    }

    }
  • umaragavan21
    umaragavan21
    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();
    }
    }
  • umaragavan21
    umaragavan21
    public class MulticastServer {
    public static void main(String[] args) throws java.io.IOException {
    new MulticastServerThread().start();
    }
    }
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Error log please...
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Did you include the MulticastServer class first???
  • umaragavan21
    umaragavan21
    ya i included.
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Oki, send the error log here... Please wrap it up in code tags... ๐Ÿ˜€
  • umaragavan21
    umaragavan21
    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"'
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Dude, that's what I said, you haven't included the class MulticastServerThread correctly!!! Include it and it works... ๐Ÿ˜€
  • umaragavan21
    umaragavan21
    ya now it works without error but when i run MulticastServer i am getting an error couldnot open quote file.Serving time instead
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Woah.. Congrats,., ๐Ÿ˜€

You are reading an archived discussion.

Related Posts

Hi sir, i have passed my SSC examination this year and i want to do diploma in chemical engineering.So what can i do for it? and will you elaberate scope...
I'm a student at NMIMS University Mumbai, pursuing MBATECH(IT), in the Fourth Year Click Here I want to make a career as a business analyst in the tablet & smartphone...
hello every member , i am a newbie to CE just about to complete B.Tech. in EC from Nirma University ahmedabad..born and brought up in mathura..placed in infosys and cognizant..gotta...
Hello All, Here we are again with the latest issue of ClubHack Magazine. This time also the issue is dedicated to Browser security. ClubHack Magazine: Direct Download: Tech Gyan -...
Friends, I have a little doubt. Now to be frank, My aggregate percentage is coming out to be 65%. I have completed III year mechanical engineering. I have one year...