title: Python Server NameError: global name 'SocketError' is not defined
body: <p>I wanted to make a connection between a sever and a client, so the server sends a string to the client.</p>
  
  <p><strong>Here is the Server:</strong></p>
  
  <pre><code>import socket
  
  def Main():
      host = '190.176.141.23'#ip changed
      port = 12345
  
      while True:
  
          s = socket.socket()
          s.bind((host,port))
  
          s.listen(1)
          c, addr = s.accept()
          print "Connection from: " + str(addr)
  
  
          command = c.recv(1024)
  
          if command == 'GIVETEXT':
              c.send('test')
  
          try:
              c.close()
              sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
          except SocketError as e:
              if e.errno != errno.ECONNRESET:
                  raise
              pass
  
  if __name__ == '__main__':
      Main()
  </code></pre>
  
  <p><strong>And here is the Client I made:</strong></p>
  
  <pre><code>import socket
  
  class Client(object):
  
      def __init__(self, *args):
          self.s = socket.socket()
  
      def sent(self, host, port):
          self.s.connect((host, port))
          self.s.send('GIVETEXT')
          self.Text = self.s.recv(1024)
          print self.Text
          self.s.close
          return self.Text
  </code></pre>
  
  <p>Needless to say, that I executed the method in another piece of code, and it worked. But after that the server crashed, with the error message:</p>
  
  <pre><code>NameError: global name 'SocketError' is not defined
  </code></pre>