This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Ruby Server Pinger -- by Umby24

By: a guest on Jan 15th, 2012  |  syntax: Ruby  |  size: 0.46 KB  |  views: 786  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data