Generalizing socket server.