How to Simulate the Behaviour of Server Not Running
- Start the client without starting the server.
- Type in a single line to client, nothing happens.
- Client blocks forever in recvfrom,the function that handles receiving messages (waits for messages) from server, waiting for server reply.
Consider an Example
UDP client sends 3 datagrams to 3 different servers (3 different IP addresses) on single UDP socket. Client then enters loop that calls recvfrom to read replies. 2 datagrams correctly delivered (server was running on 2 out of 3 hosts), but third host was not running server and responds with ICMP port unreachable.
ICMP error message contains IP header and UDP header of datagram that caused error. Client needs to know destination of datagram that caused error. recvfrom only returns errno value, not IP address or UDP port number of destination of erring datagram. Thus, asynchronous errors are returned to process only if process connected UDP socket to exactly one peer.