This repository has been archived on 2024-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
redstoner.com/app/helpers/application_helper.rb
2013-10-07 04:59:21 +02:00

17 lines
374 B
Ruby

module ApplicationHelper
def port_open?(host, port)
wait = 300/1000.0 #milliseconds, the .0 is required!!
require 'timeout'
require 'socket'
isopen = false
begin
Timeout::timeout(wait) {
TCPSocket.new host, port
isopen = true
}
rescue Exception
# could not connect to the server
end
return isopen
end
end