1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-14 14:28:05 +11:00
OC-Minitel/util/OpenOS/usr/bin/ping.lua

21 lines
543 B
Lua
Raw Normal View History

local net = require "minitel"
2018-07-25 21:05:50 +10:00
local computer = require "computer"
local event = require "event"
local tArgs = {...}
local addr = tArgs[1]
local times = tonumber(tArgs[2]) or 5
local wait = tonumber(tArgs[3]) or 30
for i = 1, times do
local ipt = computer.uptime()
local pid = net.genPacketID()
computer.pushSignal("net_send",1,tArgs[1],0,"ping",pid)
local t,a = event.pull(wait,"net_ack",pid)
if t == "net_ack" and a == pid then
print("Ping reply: "..tostring(computer.uptime()-ipt).." seconds.")
else
print("Timed out.")
end
end