Ported to Python 3.

Most of the transition was handled by the 2to3 tool with minimal
changes, but some of the imports had to be tweaked, and the
string handling in socketproto fixed.
Added a quit command to the tool to terminate the server.