Help with UDP in Ethernet library

I'm trying to initialize a UDP connection with a remote PC but the two elements (ethernet shield and remote host) seems to have trouble with beginning the connection.
I only need to send packets from Ethernet shield.
The shield just keeps sending ARP messages and there seems to be no response from PC (I'm monitoring with Wireshark).
Once I manually send a UDP packet from PC (by using packet sender), only the session begins.
I believe there's something wrong with my code. Any guidance would be helpful.

void loop() {
  Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
  Udp.write("Test 1234");

Just figured it out by myself. I only needed to add

Udp.beginMulticast(remoteIP, remotePort);

at the beginning.

Multicasts are messages that are broadcasted over your entire network.
This is not state of the art.
If you want to do it properly, set your PC up with a fixed IP address and then use the address as the first parameter in beginPacket(); Use a fixed value for remotePort as well.
As UDP is connectionless (fire and forget) this is the alternative to broadcast.
The other alternative is to first send something from the PC to the Arduino with a fixed ip address and then remember the address the message came from.
Best Regards,

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.