Udp Client Multi Receive : Udp Client « Network « C# / C Sharp






Udp Client Multi Receive


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.Test Udp Client
2.Time out Udp Client
3.Simple Udp Client
4.Odd Udp Client
5.Retry Udp ClientRetry Udp Client
6.Exception Udp ClientException Udp Client
7.Better Udp Client
8.Best Udp ClientBest Udp Client
9.Bad Udp Client
10.Binary Udp Client
11.Udp Client Sample
12.Udp Client Multi Send