mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-23 10:38:05 +11:00
added a ping util
This commit is contained in:
parent
57606424ca
commit
e2dddc542a
20
util/OpenOS/usr/bin/ping.lua
Normal file
20
util/OpenOS/usr/bin/ping.lua
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
local net = require "net"
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user