Refactor to use standard SocketServer RequestHandler design (new pull)

The original pull request #72 was closed by mistake; this one is a replacement for that one, since it seems impossible to reopen a pull request. 

Also see pull #110; my suggestion is to merge that one first.