Re: Using the broadcast address
Re: Using the broadcast address
- Subject: Re: Using the broadcast address
- From: Joshua Graessley <email@hidden>
- Date: Thu, 16 May 2002 15:17:26 -0700
On Thursday, May 16, 2002, at 09:07 AM, Joel Bender wrote:
Open a datagram socket, using the port number that will be shared by all of the cooperating applications.
Take your network mask and invert it. This is the host number. Or it with your IP address and you'll get the destination address for your broadcast.
Alternatively, just send your messages to 255.255.255.255, which will also get to everybody.
Note that UDP broadcasts are not forwarded by routers. They may also be blocked by other intervening equipment like cable modems. You could 'flood' the network by sending your message to every valid host in the range, but that it not recommended (network traffic analyzers will flag this as a 'service scan attack' and you'll get some angry calls from network admins).
While you can use a broadcast to do this, I would recommend using a link-local multicast. If you use the broadcast address 255.255.255.255, the kernel will translate it in to the broadcast for one of the networks attached. If you're on the 192.168.254.* subnet, the broadcast would be 192.168.254.255. This broadcast will be received by all nodes on the local network that have an address on the 192.168.254 subnet but it will be ignored by any other nodes. If there was another node with a 169.254.16.27 address, it would not receive your broadcast packet.
If you use link-local multicast, all local nodes will have a chance to receive the packet regardless of the subnet they're on.
-josh
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.