PowerTCP Sockets for .NET

from $349.00
Available Platforms

Windows Forms UDP Multicast Code Example

See all PowerTCP Sockets for .NET Samples and Code Examples


The following C# example demonstrates a UDP session in a Windows Forms environment. The app joins a multicast group, sends a message, receives a response and leaves. The session is executed asynchronously, without blocking the UI.


private void buttonHello_Click(object sender, EventArgs e)
    //This application has a User-Interface, which we do not want to block.
    //Start launches the specified method on a worker thread.
    udp1.Start(sendHello, new Dart.Sockets.IPEndPoint("", 59877));

private void sendHello(object groupEP)
    //Join a multicast group, send a message, receive a response, and leave.
    //The group endpoint is passed into the function.
    Dart.Sockets.IPEndPoint ep = (Dart.Sockets.IPEndPoint)groupEP;

    //Join Multicast group.

    //Send message.
    udp1.Send("hello world", ep);

    //Receive response.
    byte[] buffer = new byte[1024];

    //Leave group.


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