Interview Questions

How can I read ICMP errors from "connected" UDP sockets?

Unix Socket FAQ for Network programming


(Continued from previous question...)

How can I read ICMP errors from "connected" UDP sockets?

If the target machine discards the message because there is no process reading on the requested port number, it sends an ICMP message to your machine which will cause the next system call on the socket to return ECONNREFUSED. Since delivery of ICMP messages is not guarenteed you may not recieve this notification on the first transaction.

Remember that your socket must be "connected" in order to receive the ICMP errors.

(Continued on next question...)

Other Interview Questions