title: Python SSL example from docs gives "Connection reset by peer" error
body: <p>I'm trying to run the example code provided in the documentation for the <code>ssl</code> module here: <a href="http://docs.python.org/2/library/ssl.html#client-side-operation" rel="nofollow">http://docs.python.org/2/library/ssl.html#client-side-operation</a></p>
  
  <p>The server-side code is similar to the example given in the documentation, and it throws this exception:</p>
  
  <pre><code>Traceback (most recent call last):
    File "serve.py", line 16, in &lt;module&gt;
      ssl_version=ssl.PROTOCOL_TLSv1)
    File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket
      ciphers=ciphers)
    File "/usr/lib/python2.7/ssl.py", line 143, in __init__
      self.do_handshake()
    File "/usr/lib/python2.7/ssl.py", line 305, in do_handshake
      self._sslobj.do_handshake()
  socket.error: [Errno 104] Connection reset by peer
  </code></pre>
  
  <p>And the client-side code, also similar to the example in the documentation, throws this exception:</p>
  
  <pre><code>Traceback (most recent call last):
    File "client.py", line 8, in &lt;module&gt;
      ssl_sock.connect((host, port))
    File "/usr/lib/python2.7/ssl.py", line 331, in connect
      self._real_connect(addr, False)
    File "/usr/lib/python2.7/ssl.py", line 324, in _real_connect
      raise e
  socket.error: [Errno 104] Connection reset by peer
  </code></pre>
  
  <p>As far as I can see, I've copied the examples provided in the documentation quite closely, so I don't know what the problem is. All of my TCP, UDP and ICMP ports are open, so I don't think it is a firewall issue.</p>
  
  <p><sub>(I've edited this question to cut out my code for brevity, as it really is quite similar to the example provided in the link. If you want to see my code, look at the history of this question.)</sub></p>