class McQuery::Ping
Attributes
motd[R]
players_max[R]
players_online[R]
protocol_version[R]
server_version[R]
Public Class Methods
new(hostname, port)
click to toggle source
# File lib/McQuery/ping.rb, line 6 def initialize(hostname, port) @hostname = hostname @port = port doPing end
Private Instance Methods
doPing()
click to toggle source
# File lib/McQuery/ping.rb, line 13 def doPing s = TCPSocket.open(@hostname, @port) s.puts "\xFE\x01" repl = s.gets s.close qstring = repl[3,repl.length].force_encoding("utf-16be").encode("utf-8") qarray = qstring.split("\0") qdict = {} @protocol_version = qarray[1] @server_version = qarray[2] @motd = qarray[3] @players_online = qarray[4] @players_max = qarray[5] end