Working socket server implementation with ad hoc ports