UDP Broadcast with Ethernet Shield?

I have an Arduino Leonardo and the official Arduino Ethernetshield. I want to do UDP broadcast. However, I noticed that in most guides, it requires a target port and a target IP. How do I do just a universal broadcast?

See: Ethernet - Arduino Reference

Also, I have read that the Ethernet shield uses digital pin 2. On the leonardo, this is the SDA pin for I2C communication. Will this be an issue? I write my code so that it receives all it's I2C messages first, before sending out a UDP.

I think you still need to use a port and ip, but for broadcast, the ip is You should take a look at the dhcp files for the ethernet shield. It does a broadcast for a dhcp server discovery.

Do I just choose a random port and have all devices listen in on that port? I've actually never used UDP before so I don't know how it works.

Basically, yes. But they must be listening for a broadcast on that port. DHCP servers listen on port 67.

Hey, guys. I have a question on making a udp broadcast.
I have success on making a udp broadcast at on a port. And I could receive the messages.
But if i block the port through my router setting. How come I still could receive message?
sorry if i have limited understanding on networking stuff.

The router firewall only affects traffic that goes into or through the router. If both devices are localnet, like on a switch, then the router firewall won't block it. That is the job of the computer firewall.

It will block traffic from one localnet to another on the same router. That is going through the router. In one interface and out another.