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_portObject

Returns a free port.



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

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

  port
end