UdpClient.JoinMulticastGroup : UdpClient « System.Net.Sockets « C# / C Sharp by API






UdpClient.JoinMulticastGroup

  

using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

public class UdpClientMultiRecv
{
   public static void Main()
   {
      UdpClient sock = new UdpClient(9050);
      Console.WriteLine("Ready to receive...");

      sock.JoinMulticastGroup(IPAddress.Parse("192.100.0.1"), 50);
      IPEndPoint iep = new IPEndPoint(IPAddress.Any, 0);
      byte[] data = sock.Receive(ref iep);
      string stringData = Encoding.ASCII.GetString(data, 0, data.Length);
      Console.WriteLine("received: {0}  from: {1}", stringData, iep.ToString());
      sock.Close();
   }
}

   
    
  








Related examples in the same category

1.UdpClient.DropMulticastGroup
2.UdpClient.EnableBroadcast
3.UdpClient.Receive
4.UdpClient.Send