PowerTCP Sockets for .NET

from $349.00
Available Platforms

UDP Multicast Code Example

See all PowerTCP Sockets for .NET Samples and Code Examples


The following C# example demonstrates a UDP session in a console environment. The app joins a multicast group, sends a message, receives a response and leaves.


Udp udp1 = new Udp();
string groupEpAddress = "";
int groupEpPort = 59877;
string message = "hello world";

Dart.Sockets.IPEndPoint groupEp = new Dart.Sockets.IPEndPoint(groupEpAddress, groupEpPort);

//Join Multicast group.

//Send message.
Console.WriteLine("Sending: {0}", message);
udp1.Send(message, groupEp);

//Receive response.
byte[] buffer = new byte[1024];
Datagram response = udp1.Receive(buffer);

//Leave group.

Console.WriteLine("Received: {0}", response.ToString());
Console.WriteLine("Press <Enter> to exit.");

To download a trial please visit the PowerTCP Sockets for .NET product page.