Tweaked the server so that connection can be cancelled if needed.