Tuesday, November 22, 2005

Listening to UDP broadcasts

I found the following statement on MSDN:

"The UdpClient class can broadcast to any network broadcast address, but it cannot listen for broadcasts sent to the network. You must use the Socket class to listen for network broadcasts."

However this simple UdpClient:

client = new UdpClient( 1234 );
point = new IPEndPoint( IPAddress.Any, 0 );
while (true)
{
Console.WriteLine(Encoding.ASCII.GetString( client.Receive( ref point ) ));
}

works equally well for broadcasted (*.255) as well as unicasted (*.131) udp packages.

I am confused.

No comments: