make the polling server code more reusable