Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5746

C# question

$
0
0

Hello
how i can use this code with c# component?

   public void StartListener()
{
    bool done = false;

    UdpClient listener = new UdpClient(listenPort);
    IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);

    try
    {
        while (!done)
        {
            Console.WriteLine("Waiting for broadcast");
            byte[] bytes = listener.Receive( ref groupEP);

            Console.WriteLine("Received broadcast from {0} :\n {1}\n",
                groupEP.ToString(),
                Encoding.ASCII.GetString(bytes,0,bytes.Length));
        }

    }
    catch (Exception e)
    {
        Console.WriteLine(e.ToString());
    }
    finally
    {
        listener.Close();
    }
}

11 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 5746

Trending Articles