views:

100

answers:

1

I need to receive datagrams that are sent as a broadcast message by remote host connected on the same lan.

I am using UDPClient but have no idea which method to use.There is a method UDPClient.Receive but that requires as parameter a specific IPEndPoint which is obviously not wanted since it is a broadcast message that I need to receive and hence the sender is not important. Please if possible provide me with the code to receive a broadcast message. Thanks.

+2  A: 

Set up the IPEndPoint to use the ANY address:

int port = ...your port goes here...
var endPoint = new IPEndPoint( IPAddress.Any, port );

Then use UDPClient.Receive as you normally would.

tvanfosson
This should be the accepted answer.
SoMoS