check for the server closing a connection that's compatible with Python 3

fixes #508