Based on the premise that UDP is a connectionless protocol I had presumed that whether a host is up or down would be irrelevant.
However, now that I'm doing testing I've discovered that when I have "connected" my UDP client socket, a write
to that socket returns an error because the server has sent back a ICMP Port Unreachable error ..
The purpose of "connecting" the UDP port (According to Stevens Unix Network Programming) is to basically caches the entry from the routing table, rather than creating a new one for each packet, which is supposed to have performance benefits.
However, this ICMP packet is causing me to lose my client socket, which is very annoying.
Can anybody shed any light on why this could be? Are there any known workarounds?
I'm using a 3p java library that doesn't account for this and just disconnects and I'll probably have to hack it to reconnect, but before I do I was kind of hoping there was something I could do at the (Linux) operating system level maybe to prevent this happening ... all investigations into socket options etc. have turned out to be unfruitful.
EDIT
In summary this isn't possible and fixing the code is the only way to do this.
The only possibility appears to be configuring iptables to block the ICMP responses but that's a bit of a sledgehammer to crack this particular nut.