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.

tvanfosson
  • 524,688
  • 99
  • 697
  • 795
saurabh
  • 2,463
  • 1
  • 18
  • 8

1 Answers1

2

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
  • 524,688
  • 99
  • 697
  • 795