Module: Homebrew::FreePort Private

Defined in:
formula_free_port.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper function for finding a free port.

Instance Method Summary collapse

Instance Method Details

#free_portInteger

Returns a free port.

Returns:

  • (Integer)


12
13
14
15
16
17
18
# File 'formula_free_port.rb', line 12

def free_port
  server = TCPServer.new 0
  _, port, = server.addr
  server.close

  port
end