Module: Solargraph::ServerMethods

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

Instance Method Summary collapse

Instance Method Details

#available_portInteger

Returns:

  • (Integer)


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

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