Choose untaken ports rather than guessing.

The current method of choosing server ports guesses wrong on occasion. This fixes that.