In networking you have the layers of the OSI model:
- Data link (MAC layer)
- Network (IP layer)
- Transport (TCP layer)
The data link layer and network layer are both broken out into segments by your router. This means that you can broadcast to all hosts on your VLAN (typically in the same subnet) by either layer 2 or 3. For example if you have 4 computers plugged into a single switch on the same vlan and in IP range 192.168.1.0/24 you can send a packet that will be broadcast to all 4 computers using either of the following methods:
- Layer 2: Send a frame out to mac address ff:ff:ff:ff:ff:ff
- Layer 3: Send an IP packet out to IP address 192.168.1.255
If you're planning on using TCP or UDP I would go with the layer 3 broadcast. If you're planning on connecting to machines that do not have IP addresses go with layer 2.
To be clear you're not going to be able to use broadcast packets to find hosts on different subnets. For this you would need a central server or something like multicast which must be supported and enabled on all of your routers.