Advertisement
Guest User

Ruby Server Pinger -- by Umby24

a guest
Jan 15th, 2012
1,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.46 KB | None | 0 0
  1. require 'socket'
  2. def getit(ip,port)
  3.   s = TCPSocket.open(ip,port)
  4.   s.send(254.chr,0)
  5.   d = s.read(256)
  6.   s.close()
  7.   if d.getbyte(0) == 255
  8.     mystring = d[3,d.length - 3]
  9.     mysplit = mystring.split(167.chr.to_s,4)
  10.     motd = mysplit[0]
  11.     motd = motd.encode("us-ascii")
  12.     online = mysplit[1]
  13.     online = online.encode("us-ascii")
  14.     max = mysplit[2]
  15.     max = max.encode("us-ascii")
  16.    return "#{motd} - #{online}/#{max}".gsub(0.chr,"")
  17.   end
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement