Adapt PY3 socket.__init__ API and close sockets in server.py