Top Level Namespace

Defined Under Namespace

Modules: Madeira

Instance Method Summary collapse

Instance Method Details

#openport?(host, port) ⇒ Boolean

FIXME: move method out of UI into a helper somewhere

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/madeira/ui/create_command.rb', line 51

def openport?(host,port)
  require 'socket'
  begin
    aSock = Socket.new(:INET, :STREAM)
    raw = Socket.sockaddr_in(port, host)
    if aSock.connect(raw)
      true
    end
  rescue (Errno::ECONNREFUSED)
    false
  rescue (Errno::ETIMEDOUT)
    exit_now!('timed out waiting for instance to be available.')
  end
end