Firstly, there is the concept of "connected UDP" and it is supported both by
Windows and UNIX. This provides two things:
1. The ability to use send() instead of sendto(); i.e. the socket remembers
where you want the datagrams to go.
2. A "collector" for errors such as "there's no host" that are triggered by
ICMP messages that TCP handles but which standard unconnected UDP does not.
Note that "connected UDP" does NOT create any additional flows "on the wire"
and there is no difference between unconnected/unconnected,
connected/unconnected and connected/connected pairs of sockets if you follow
the data flows using Ethereal.
Secondly, ICMP is the method through which "this address is unreachable",
and other errors, are reported to most IP stacks. The stack uses these to,
for example, generate a connect() error if using TCP.
By using connected UDP, UNIX allows the following behaviour.
- First UDP send "just goes". There have been no earlier data flows so the
sender has no idea whether the datagram will reach the destination or not.
- Subsequent send() request MAY fail if an ICMP has told the IP stack that
the first UDP datagram could not be routed.
This functionality means that UDP based protocols, which often have
"retransmit until I get a response" strategies, have a way of detected "the
target address ain't listening" without having to wait for lengthy timeouts.
Unfortunately, this doesn't seem to work on MS Windows so I'm trying to find
out whether there is some special option that needs to be set.
Paul DS.