1module Acceptance 2 ### 3 # A utility class for generating the next available bind port that is free 4 # on the host machine 5 ### 6 class PortAllocator 7 def initialize(base = 6000) 8 @base = base 9 @current = base 10 end 11 12 # @return [Integer] The next available port that can be bound to on the host 13 def next 14 # TODO: In the future this could verify the port is free, and attempt to avoid TOCTTOU issues 15 @current += 1 16 end 17 end 18end 19 20