0 Replies Latest reply on Nov 16, 2012 1:30 AM by 974540

    MulitcastSocket with same port

      I am trying to use two separate programs to listen two multicast groups ( and

      Two programs are received all of messages sent by both groups

      I can solve this problem by comment the following statement on C++ program, but I don't know how to do this on Java

      Program code: (C++)
      //localsock.sin_addr.s_addr = htonl(INADDR_ANY); <--- comment this statement
      localsock.sin_addr.s_addr = inet_addr( m_sMulticastGrp.c_str() );
      localsock.sin_port = htons(m_nPort);

      Program code: (Java)

      NetworkInterface networkInterface = new NetworkInterface.getByName(args[1]); //args[1] = eth0
      MulticastSocket socket = new MulticastSocket(51000);
      socket.joinGroup(args[0]); //args[0] = or


      DatagramPacket packet = new DatagramPacket(buf, buf.length);
      while (true){
      }catch(IOException ex){