Module: Homebrew::FreePort Private

Defined in:
Library/Homebrew/formula_free_port.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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 'Library/Homebrew/formula_free_port.rb', line 13

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

  port
end