harper
harper

Reputation: 13690

Send UDP broadcast on Windows 7

I have a PC with two network cards connected to different networks (multi homed network setup). I want to send UDP broadcast frames on both networks. The senders IP address of the frames must be the IP address of the adapter, that is used to send the frame. The destination address should be the LIMITED BROADCAST address.

The customer application should not run with administrative rights (UAC is not acceptible).

How can I send these UDP frames to the LIMITED BROADCAST address (255.255.255.255)? How could I send these frames to the NETWORK BROADCAST address (x.y.z.255)?

I know how to do this with raw sockets. But raw sockets can only be used with administrative rights.

Upvotes: 5

Views: 9543

Answers (1)

Len Holgate
Len Holgate

Reputation: 21616

Can't you just open two normal UDP sockets and bind one to each of the interface addresses and then simply send to the broadcast addresses ?

This will, as far as I know, deal with the sending on both networks and it will ensure that the packets sent will have the correct ip address. It wont work if you bind a single socket to INADDR_ANY which, of course, WILL work if there's only a single network adapter in the machine. To create a complete solution it's probably best to iterate over the available addresses and create a socket for each, bind to each and send from each.

Upvotes: 3

Related Questions