Module: Solargraph::ServerMethods

Included in:
Shell
Defined in:
lib/solargraph/server_methods.rb

Instance Method Summary collapse

Instance Method Details

#available_portInteger

Returns:

  • (Integer)

6
7
8
9
10
11
12
# File 'lib/solargraph/server_methods.rb', line 6

def available_port
  socket = Socket.new(:INET, :STREAM, 0)
  socket.bind(Addrinfo.tcp("127.0.0.1", 0))
  port = socket.local_address.ip_port
  socket.close
  port
end