I agree that UDP is connection less. But RFC 1122, which mandates the behaviour of Linux for UDP protocol states that whenever ICMP error messages are received, they should be reported to the user application.
I do get "Connection refused" errors for sending data to a non existent UDP socket on a reachable host. Why shouldn't I get an error for a non existent port on an unreachable host?
And as per the content of my post, if SO_BSDCOMPAT option is on, then you get errors if and only if the destination host is up but there is some problem in connecting to the socket.
The UDP man page also states that SO_BSDCOMPAT option has been removed after Linux 2.2. I have Linux 2.6. So why is my application behaving as if SO_BSDCOMPAT option is set?