I think I'd prefer to have an optional listen port parameter on the Session constructor and do the randomization outside. The problem and solution doesn't really belong here, but it could be enabled.