First, if you are using broadcast and network classes then you are still stuck in the last century. Network classes are dead.
Broadcasts interrupt every host on the LAN (routers, printers, all PCs, etc.), including those not interested in the broadcast. Many companies now will reject applications that use broadcast because it interrupts every host, and it can be a security problem. In fact, IPv6 has eliminated broadcast, and if your application relies on broadcast, you cannot simply port it to IPv6. Also, broadcasts will not cross a router.
The modern way to do things is to use multicast. The hosts interested will subscribe to a particular multicast group (preferably one from the Organization-Local scope of 239.0.0.0/8
). The application sending will then send to the multicast group as the destination address, and the hosts subscribed to the multicast group will get and process the packets, but other host will not be interrupted. Multicast routing can be enabled, and, unlike broadcast packets, multicast packets can be routed to other networks.
If you insist on broadcast, then simply use the limited broadcast address of 255.255.255.255
, and that will send a broadcast to every host on the LAN. Remember that broadcasts are stopped at a router, so any hosts on a different network will need a host on that network to send a broadcast.