title: Receiving ICMP Host Unreachable message on UDP socket in Python
body: <p>I'm writing a simple UDP chat server in Python 2.7 on Linux 2.6.38.</p>
  
  <p>How can ICMP error messages be read that a host(client) receives when it sends UDP segments to say, an unreachable server?</p>
  
  <p>I tried</p>
  
  <pre><code>sockFd.setsockopt( socket.IPPROTO_IP, socket.IP_RECVERR, 1 ) 
  </code></pre>
  
  <p>But <strong>socket.IP_RECVERR</strong> isn't defined in <strong>socket</strong> module.</p>
  
  <p>I tried using a timeout on sockFd.recvfrom and doing <strong>sendto</strong> a second time but that didn't help. Is there an API to read the ICMP errors received by the host? </p>