-1

with a c# application using the function : clientUDP.joinMulticastGroup(MulticastGroup) i can add a multicast address to a specific interface. The problem is: each time i run my application i add a multicast group to the a network interface, but when the app end it remain joined, so if i run again the app switching the interface it doen't work, than i need to change multicast address and again ...again... in this way i associate a lot of multicast address to each interface. If i run:

netsh interface ip show joins it shows my interface with multicast joined

Interfaccia 7: Wi-Fi

     Ambito       Referement  Ultimo  Address
     ----------   -----------  ------  ---------------------------------
     0                    0  SÌ    224.0.0.1
     0                    0  SÌ    224.0.0.3
     0                    0  SÌ    224.0.0.121
     0                    2  SÌ    224.0.0.251
     0                    1  SÌ    224.0.0.252
     0                    0  SÌ    224.0.0.253
     0                    0  SÌ    224.168.100.2
     0                    2  SÌ    224.237.248.235
     0                    0  SÌ    224.237.248.237
     0                    0  SÌ    239.255.255.3
     0                    3  SÌ    239.255.255.250

The question is: HOW CAN I REMOVE THIS MULTICAST JOINED FROM EACH INTERFACE ? There is a shell command only or something i can do on c# too?

1 Answers1

0

My Code (it works only first time i launch my app, than if i run a second time i need to change the multicast address):

     private static readonly IPAddress GroupAddress =IPAddress.Parse("224.237.248.235");
     private const int GroupPort = 64555;
     private static IPEndPoint groupEP = new IPEndPoint(GroupAddress, GroupPort);
    //server udp
    private static UdpClient serverUDP = new UdpClient(GroupPort);
    //client udp
    private static UdpClient clientUDP = new UdpClient();
    private static IPEndPoint remoteEpClient = null;

manage

         clientUDP.JoinMulticastGroup(GroupAddress, IPAddress.Parse(LANSharingApp.umu.GetLocalIP()));
         remoteEpClient = new IPEndPoint(GroupAddress, GroupPort);
         serverUDP.JoinMulticastGroup(GroupAddress);

for send

          clientUDP.Send(ASCIIEncoding.ASCII.GetBytes(message), ASCIIEncoding.ASCII.GetBytes(message).Length, remoteEpClient);

for receive bytes = serverUDP.Receive(ref groupEP);