title: Error: nodename nor servname provided, or not known (python sockets)
body: <p>I am trying to learn how to use sockets using this tutorial:<br>
  <a href="https://www.tutorialspoint.com/python/python_networking.htm" rel="nofollow noreferrer">https://www.tutorialspoint.com/python/python_networking.htm</a><br>
  I have copied the code from the site into my directory and ran it exactly as was done in the tutorial but got errors. Here is the code from the tutorial.</p>
  
  <pre><code>#!/usr/bin/python           # This is server.py file
  
  import socket               # Import socket module
  
  s = socket.socket()         # Create a socket object
  host = 'localhost' # Get local machine name
  port = 12345                # Reserve a port for your service.
  s.bind((host, port))        # Bind to the port
  
  s.listen(5)                 # Now wait for client connection.
  while True:
      c, addr = s.accept()     # Establish connection with client.
      print("asdf")
      c.send('Thank you for connecting')
      c.close()                # Close the connection
  </code></pre>
  
  <p>and client.py</p>
  
  <pre><code>#!/usr/bin/python           # This is client.py file
  
  import socket               # Import socket module
  
  s = socket.socket()         # Create a socket object
  host = socket.gethostname() # Get local machine name
  port = 12345                # Reserve a port for your service.
  
  s.connect((host, port))
  print s.recv(1024)
  s.close                     # Close the socket when done
  </code></pre>
  
  <p>These are the console commands I ran:  </p>
  
  <pre><code>python server.py &amp;
  python client.py
  </code></pre>
  
  <p>I got this errors after running the command:</p>
  
  <pre><code>Traceback (most recent call last):
    File "client.py", line 9, in &lt;module&gt;
      s.connect((host, port))
    File     "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/soc    ket.py", line 228, in meth
  return getattr(self._sock,name)(*args)
  socket.gaierror: [Errno 8] nodename nor servname provided, or not known
  </code></pre>
  
  <p>In case this is helpful, the version of python I am using is Python 2.7.10 and I use a mac that is version 10.12.6</p>
  
  <p>Thanks in advance</p>