Jump to content




Can't figure out what is wrong with this!


  • You cannot reply to this topic
2 replies to this topic

#1 Zeoic

  • Members
  • 12 posts

Posted 08 September 2012 - 02: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


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 08 September 2012 - 04: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.

#3 Zeoic

  • Members
  • 12 posts

Posted 08 September 2012 - 04:18 AM

View PostLyqyd, on 08 September 2012 - 04:07 AM, said:

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!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users