Posted 04 October 2012 - 05:01 PM
I made this new program with a client and a server, now when i ping the server from the client i get a ping back. but when i try to ping the seconed time, it doesnt work.
Server Code:
The client:
Server Code:
rednet.open("top")
stop=0
while true do
local event,p1,p2,p3 = os.pullEvent()
if event=="rednet_message" then
if p2=="$PING" then
print("Computer: "..p1.." Send a Pong request")
p1=sender
rednet.send(sender, "pong")
wait=0
while wait==0 do
local event,p1,p2,p3 = os.pullEvent()
if p2=="$GOT" then do
print("Request succesfull")
end
end
end
else
print("I Received a Message!")
print("From: "..p1.." Computer")
print("Message: "..p2.."")
print("The Distance to Computer "..p1.." is "..p3.." Blocks")
end
end
end
The client:
print("Please input master server ID")
masterserver1 = tonumber(read())
rednet.send(masterserver1, "$PING")
x=0
while x==0 do
rednet.send(masterserver1, "$PING")
local event,p1,p2,p3 = os.pullEvent()
if event=="rednet_message" then
rednet.send(29, "$GOT")
print(""..p1.."")
print(""..p2.."")
x=1
end
end