Background: I have four absolute rotary encoders that I read from positions from and outputs the result on the network using the EthernetUDP library.
Problem: If I start my project without the ethernet cable plugged in the UDP.beginPackage() ... UDP.endPackage() take a while (maybe 1-2 seconds). However, if I plug in the cable and then plugs it out again the package sending is fast.
I'm assuming that some kind of network magic (maybe ARP?) is done in the background and if the ethernet cable is not plugged in it will try each time?
Can I avoid this behavior? Is there a Ethernet.isPluggedIn() function that I can call?
Which version of the beginPacket() do you use? The one with an IP address or the one with a hostname?
Can I avoid this behavior? Is there a Ethernet.isPluggedIn() function that I can call?
To my knowledge the WizNet5100 chip doesn't allow to check the link state of the ethernet connection. You can lower the timeout value and decrease the retry count to be informed faster about a failing communication but you might get that information also if the network is just a bit slower.
pylon:
You can lower the timeout value and decrease the retry count to be informed faster about a failing communication but you might get that information also if the network is just a bit slower.
edit: BTW, endPacket() returns a value. If the return value is 1, the packet was sent successfully, else send failed. This means "sent to the next device". It indicates delivery to the destination only if the destination device is on the sender's localnet.
And setRetransmissionCount is a misnomer. To be technically correct, it should have been called "setAttemptCount". You can't set that to zero. If you do, it will never try to send the packet.