title: Why can't python socket resolve domain name here?
body: <p>I'm using python socket to connect to a server for logging purpose. The IP address of the server is <code>x.x.x.x</code> (I just hide this, <code>x</code> can be number from 0 to 255) and, and my domain name could be <code>www.example.domain.com</code>. I've written this <code>x.x.x.x www.example.domain.com</code> in <code>/etc/hosts</code> with <code>sudo</code> access. However, when I tried to use the domain name in my program, python socket just failed to resolve the domain name. </p>
  
  <pre><code>import socket
  
  mysocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  '''Block of code'''
  mysocket.sendto('Hello!', 'www.example.domain.com')
  mysocket.close()
  </code></pre>
  
  <p>The error message here is: </p>
  
  <blockquote>
    <p>socket.gaierror: [Errno 8] nodename nor servname provided, or not
    known</p>
  </blockquote>
  
  <p>If I change <code>www.example.domain.com</code> to a plain text host name such as <code>testLogger</code>, python socket is able to resolve that. I can <code>ping</code> the domain name on my machine, so I'm just wondering why python socket can't resolve the domain name in this scenario.</p>