I'd try the following:

http://stackoverflow.com/questions/1096142/broadcasting-udp-message-to-all-the-available-network-cards
http://snipplr.com/view/28192/bind-a-socket-including-udpclient-and-tcpclient-to-a-local-network-interface-card-nic/

HTH

On Mon, Dec 13, 2010 at 5:56 PM, Greg Keogh <g...@mira.net> wrote:
> Folks, I’ve got old code that sends UDP broadcasts like this simple
> skeleton:
>
>
>
> UdpClient broadcaster = new udpClient();
>
> IPEndPoint ep = new IPEndPoint(IPAddress.Broadcast, 8888);
>
> Broadcaster.Send(buffer, buffer.Length, ep);
>
>
>
> We have just found that if there are multiple network cards in the machine
> then it’s unpredictably broadcasting on the wrong interface and the
> listeners get nothing. I’m not sure how to code a fix for this. Do I need to
> do this to get an IPAddress array and then put them all into the Send call?
> Like this...?
>
>
>
> string hostname = Dns.GetHostName();
>
> IPHostEntry he = Dns.GetHostByName(hostname);
>
> foreach (IPAddress addr in he.AddressList)
>
> {
>
>     // Send with an endpoint set to each addr instead of
> IPAddress.Broadcast?
>
> }
>
>
>
> I’m not sure if this is the correct technique. Any sockets boffins here know
> this sort of thing?
>
>
>
> Cheers,
>
> Greg

Reply via email to