ZNZNCOOP

ping

May 15th, 2014
168
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = { ... }
  2. if #tArgs == 0 then
  3.     print( "Usage: ping <ip> [<gateip>]" )
  4.     return
  5. end
  6.  
  7. if not open() then return end
  8. if not getIP(tArgs[2]) then return end
  9. print('Pinging '..tArgs[1])
  10. for i=1,4 do
  11.   start=os.clock()
  12.   send(tArgs[1],'ping')
  13.   mess,sIP=receive(3)
  14.   if mess then
  15.     if mess=='pong' then
  16.       print('Answer from ',sIP,' time=',os.clock()-start)
  17.     else
  18.       print(sIP,': ',mess)
  19.     end
  20.   else
  21.     print('Time out')
  22.   end
  23.   sleep(1)
  24. end
RAW Paste Data