Multicast in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pb2000
    New Member
    • Apr 2010
    • 13

    Multicast in java

    Hello,

    I work with Client/Server example as below:

    Code:
    public class Client {
    public static void main(String[] args) throws IOException,
    ClassNotFoundException {
    InetAddress address = InetAddress.getByName("225.6.7.8");
    MulticastSocket socket = new MulticastSocket(56565);
    socket.joinGroup(address);
    byte[] buffer = new byte[1024];
    DatagramPacket datagram =
    new DatagramPacket(buffer, buffer.length);
    socket.receive(datagram);
    System.out.println(">>> " + datagram.getData()[0]);
    socket.leaveGroup(address);
    }
    }
    Code:
    public class Server {
    public static void main(String[] args) throws IOException,
    ClassNotFoundException {
    InetAddress address = InetAddress.getByName("225.6.7.8");
    DatagramSocket socket = new DatagramSocket();
    byte[] buffer = new byte[1024];
    buffer[0] = 123;
    DatagramPacket datagram =
    new DatagramPacket(buffer, buffer.length, address, 56565);
    socket.send(datagram);
    System.out.println("<<< " + datagram.getData()[0]);
    }
    }
    Is it possible to run those on computers belonging to simple lan?. For instance:
    10.10.5.2
    10.10.5.9

    Possibly I did not understand multicast correctly - (should be just logical network over normal physical IP of B,C class)?
  • pb2000
    New Member
    • Apr 2010
    • 13

    #2
    Solved. Sorry for stupid question. I am newbie at networking.

    Comment

    Working...