Fix server port number assignation

We addressed this in #557 and #558, and now we’re centralizing the
functionality. Per #564.