Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bool_server_status(servername, ipaddress)
- ipvalue = IPAddr.new(ipaddress)
- status = 0
- route = ""
- if !File.exists?("statefiles/" + servername + ".STATE")
- status = 2
- end
- if File.exists?("statefiles/" + servername + ".STATE")
- state = "statefiles/" + servername + ".STATE"
- route = open(state).gets
- begin
- timeout(3) do
- begin
- t = TCPSocket.new(ipvalue, 1734)
- rescue
- status = 0
- else
- # ... do something with the socket
- t.print "PARADIGM"
- line = t.gets
- #while line = t.gets # Read lines from the socket
- puts line # And print with platform line terminator
- #end
- if (line == "Recieved")
- status = 1
- t.close
- return status
- end
- @val = 1
- #end
- end
- end
- rescue Timeout::Error
- status = 0
- end
- end
- return status
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement