View difference between Paste ID: 7KBsDXXe and 7PWEBgac
SHOW: | | - or go back to the newest paste.
1-
network = require("network")
1+
network = require("network")
2-
event = require("event")
2+
event = require("event")
3-
computer = require("computer")
3+
computer = require("computer")
4-
send_payload = "mothertrucking"
4+
send_payload = "mothertrucking"
5-
5+
6-
toping = {"EnderRemote", "EnderOne", "EnderTwo", "EnderThree", "Super", "SuperTablet"}
6+
toping = {"EnderRemote", "EnderOne", "EnderTwo", "EnderThree", "SuperServer", "SuperTablet", "FileServer"}
7-
pingids = {}
7+
pingids = {}
8-
8+
9-
for index,host in pairs(toping) do
9+
function process_ping(e, addr, id, payload)
10-
pid = network.icmp.ping(host, send_payload)
10+
name = pingids[id].host
11-
pingids[pid] = {host=host, time=computer.uptime()}
11+
time = pingids[id].time
12
time = computer.uptime()-time
13-
13+
print(name.." ["..addr.."]".. "  "..time)
14-
while true do 
14+
if payload ~= send_payload then print("Warning, Payload bad: "..payload) end
15-
e, addr, id, payload = event.pull("ping_reply")
15+
end
16-
name = pingids[id].host
16+
17-
time = pingids[id].time
17+
event.listen("ping_reply", process_ping)
18-
time = computer.uptime()-time
18+
19-
19+
for index,host in pairs(toping) do
20-
print(name.." ["..addr.."]".. "  "..time)
20+
pid = network.icmp.ping(host, send_payload)
21-
if payload ~= send_payload then print("Warning, Payload bad: "..payload) end
21+
pingids[pid] = {host=host, time=computer.uptime()}
22-
22+