code: func (s *PortManager) PickEphemeralPort(testPort func(p uint16) (bool, *tcpip.Error)) (port uint16, err *tcpip.Error) {
  	count := uint16(math.MaxUint16 - FirstEphemeral + 1)
  	offset := uint16(rand.Int31n(int32(count)))
  
  	for i := uint16(0); i < count; i++ {
  		port = FirstEphemeral + (offset+i)%count
  		ok, err := testPort(port)
  		if err != nil {
  			return 0, err
  		}
  
  		if ok {
  			return port, nil
  		}
  	}
  
  	return 0, tcpip.ErrNoPortAvailable
  }
docs: // PickEphemeralPort randomly chooses a starting point and iterates over all
  // possible ephemeral ports, allowing the caller to decide whether a given port
  // is suitable for its needs, and stopping when a port is found or an error
  // occurs.