This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Zeoic's profile picture

Can't figure out what is wrong with this!

Started by Zeoic, 08 September 2012 - 01:56 AM
Zeoic #1
Posted 08 September 2012 - 03:56 AM
I am trying to make a browser of sorts. There is a browser server and a browser client. Its asks the client for the url the sends it to the server, and if the url is the same as the one on the server it will send back the webpage text. BUT IT DOESN'T WORK! I have been trying for hours and can't figure it out… Please help me!

Browser Client (Program Name: browser)


rednet.open("top")
term.clear()
term.setCursorPos(1,1)
print("--------------------------------------------------")
term.setCursorPos(1,1)
print("Enter URL: ")
term.setCursorPos(12,1)
page = read()
rednet.send(1, page)
sleep(1)
local senderId, message = rednet.receive(3)
term.setCursorPos(1,4)
if message == nill then
print("Opps! Somthing didn't work!")
else
print(message)
end

Browser Server (Program Name: browserserver)


print("Browser Server Running...")

local webpage = "Google"
while true do
local id, message = rednet.receive()

if message == "google" then
rednet.send(id, webpage)
print("Computer, ".. id .. ", went to " .. message)
end
end
Lyqyd #2
Posted 08 September 2012 - 05:07 AM
Get rid of the sleep(1). Sleep calls cause all events between the start of the sleep and the end of the sleep to be discarded. The data is being sent to the client during this period of time, and as such is being discarded by the client while it is waiting for the sleep timer to expire.
Zeoic #3
Posted 08 September 2012 - 05:18 AM
Get rid of the sleep(1). Sleep calls cause all events between the start of the sleep and the end of the sleep to be discarded. The data is being sent to the client during this period of time, and as such is being discarded by the client while it is waiting for the sleep timer to expire.

OMG thank you sooo much! It worked!