0

I have a C# .net 3.5 application where I use System.Net.Sockets.Socket.SendTo() to send a UDP frame to the multicast address 224.0.100.1. I then use BeginReceiveFrom() on the same socket to listen for all the responses.

But, on systems where there is more than one network adapter, it seems to be random on which adapter the UDP packet is sent.

How can I allow the user the option to select the adapter that will be used and force SendTo() to use that address?

Thanks, PaulH

PaulH
  • 7,759
  • 8
  • 66
  • 143
  • see that: http://stackoverflow.com/questions/4822968/win32-sockets-forcing-ip-packets-to-leave-physical-interfaces-when-sending-to –  Apr 18 '12 at 18:03
  • @PaulH Did it work now? I am facing a smiliar problem. – Gobliins Nov 29 '12 at 10:35
  • @Gobliins Yes, it works when I use Socket.Bind(). If that doesn't work for you, post a new question with your code. – PaulH Nov 29 '12 at 15:07
  • Yea, i figured out i should use the Socket class not the UdpClient wrapper around. thx. – Gobliins Nov 29 '12 at 15:15

1 Answers1

0

Use Socket.Bind() to set the local endpoint before sending.

caf
  • 233,326
  • 40
  • 323
  • 462