fix for SF 3245627 (read loop hangs on lost connection), fix some doc typos, add debug logs
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt
index bb06f90..c4b2cca 100644
--- a/pyserial/CHANGES.txt
+++ b/pyserial/CHANGES.txt
@@ -412,3 +412,4 @@
 Bugfixes:
 
 - [SF 3093882] calling open() on an already open port now raises an exception
+- [SF 3245627] connection-lost let rfc2217 hangs in closed loop
diff --git a/pyserial/serial/rfc2217.py b/pyserial/serial/rfc2217.py
index 28cbc6a..3d05a85 100644
--- a/pyserial/serial/rfc2217.py
+++ b/pyserial/serial/rfc2217.py
@@ -402,7 +402,7 @@
             'parity':   TelnetSubnegotiation(self, 'parity',   SET_PARITY,   SERVER_SET_PARITY),
             'stopsize': TelnetSubnegotiation(self, 'stopsize', SET_STOPSIZE, SERVER_SET_STOPSIZE),
             }
-        # There are more subnegotiation object, combine all in one dictionary
+        # There are more subnegotiation objects, combine all in one dictionary
         # for easy access
         self._rfc2217_options = {
             'purge':    TelnetSubnegotiation(self, 'purge',    PURGE_DATA,   SERVER_PURGE_DATA),
@@ -577,7 +577,7 @@
             try:
                 self._socket.sendall(data.replace(IAC, IAC_DOUBLED))
             except socket.error, e:
-                raise SerialException("socket connection failed: %s" % e) # XXX what exception if socket connection fails
+                raise SerialException("connection failed (socket error): %s" % e) # XXX what exception if socket connection fails
         finally:
             self._write_lock.release()
         return len(data)
@@ -672,9 +672,12 @@
                     # just need to get out of recv form time to time to check if
                     # still alive
                     continue
-                except socket.error:
+                except socket.error, e:
                     # connection fails -> terminate loop
+                    if self.logger:
+                        self.logger.debug("socket error in reader thread: %s" % (e,))
                     break
+                if not data: break # lost connection
                 for byte in data:
                     if mode == M_NORMAL:
                         # interpret as command or as data
@@ -805,10 +808,10 @@
 
     def rfc2217SetControl(self, value):
         item = self._rfc2217_options['control']
-        item.set(value) # transmit desired purge type
+        item.set(value) # transmit desired control type
         if self._ignore_set_control_answer:
             # answers are ignored when option is set. compatibility mode for
-            # servers that answers, but not the expected ones... (or no answer
+            # servers that answer, but not the expected one... (or no answer
             # at all) i.e. sredird
             time.sleep(0.1)  # this helps getting the unit tests passed
         else:
@@ -873,7 +876,7 @@
 
 class PortManager(object):
     """This class manages the state of Telnet and RFC 2217. It needs a serial
-    instance and a connection to work with. connection is expected to implement
+    instance and a connection to work with. Connection is expected to implement
     a (thread safe) write function, that writes the string to the network."""
 
     def __init__(self, serial_port, connection, logger=None):
@@ -976,9 +979,9 @@
     # - outgoing data escaping
 
     def escape(self, data):
-        """this function is for the user. all outgoing data has to be properly
-        escaped, so that no IAC character in the data stream messes up the
-        Telnet state machine in the server.
+        """this generator function is for the user. all outgoing data has to be
+        properly escaped, so that no IAC character in the data stream messes up
+        the Telnet state machine in the server.
 
         socket.sendall(escape(data))
         """