added a ping util for testing network connectivity
This commit is contained in:
parent
ba0320fcdc
commit
15a6151748
17
exec/ping.lua
Normal file
17
exec/ping.lua
Normal file
@ -0,0 +1,17 @@
|
||||
local minitel = require "minitel"
|
||||
local event = require "event"
|
||||
local tArgs = {...}
|
||||
local addr = tArgs[1]
|
||||
local times = tonumber(tArgs[2]) or 5
|
||||
local timeout = tonumber(tArgs[3]) or 30
|
||||
for i = 1, times do
|
||||
local ipt = computer.uptime()
|
||||
local pid = minitel.genPacketID()
|
||||
computer.pushSignal("net_send",1,addr,0,"ping",pid)
|
||||
local t,a = event.pull(timeout,"net_ack")
|
||||
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