forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GET

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Mon Nov 20, 2006 10:40 pm    Post subject: GET Reply with quote

When I'm using bytesent, it really looks like I only get a response the first time I use this function. I use it like this:
Code:

bytesSent = socket:send(requeststring)
bytesSent = socket:send("User-Agent: SOBrowser\r\n")
bytesSent = socket:send("Host: so.ikhoefgeen.nl\r\n\r\n")


requeststring can be things like
"GET /?id=1 HTTP/1.0 \r\n"
"GET /?test=2 HTTP/1.0\r\n"

For those interested, here's the full function I use for this:
Code:
function GetFile(requeststring,Method,storestring)
   print("Getfile")
   buffer = nil
   data = nil
   filestart =nil
   TimeOut = 0
   if RequestOut then print(requeststring) end
   bytesSent = socket:send(requeststring)
   bytesSent = socket:send("User-Agent: SOBrowser\r\n")
   bytesSent = socket:send("Host: so.ikhoefgeen.nl\r\n\r\n")
   while true do
      buffer = socket:recv()
      if string.len(buffer) > 0 then
         print("buffer filled",buffer)
         if filestart~=1 then
            --print(buffer)
            if string.find(buffer, "\r\n\r\n") then
               data = string.sub(buffer,string.find(buffer, "\r\n\r\n")+4)
               filestart = 1
            end
         else
            data = data..buffer
            --print(data)
            --file:write(buffer)
         end
      else -- probably end of transfer
         TimeOut = TimeOut + 1
         if TimeOut == 50 then
            if data then
               if DataOut == 1 then print(data) end
               if Method == 1 then
                  assert(loadstring(storestring.."="..data))()
               elseif Method == 2 then
                  file = io.open(storestring,"w+")
                  file:write(data)
                  file:close()
               end
               GotData = true
            end
            --print(1,LevelData)
            break
         end
      end
      
      if Controls.read():start() then break end
      --screen.waitVblankStart()
   end
end


The full function call looks like this:
Code:
while not GotData do
   GetFile("GET /?test=2 HTTP/1.0\r\n",1,"LevelData")
end


I've done about 2,5 hours of debugging without result. Could it be a bug in luaplayer 0.16?
_________________
Behold! The Underminer got hold of a PSP
Back to top
View user's profile Send private message
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Mon Nov 20, 2006 11:20 pm    Post subject: Reply with quote

A friend of mine suggested that the server closes the connection af each request. Can anyone confirm this?. He also hinted that it might be possible to 'keep the connection alive' but he didn't know the details. Can anyone tell me more about this?
_________________
Behold! The Underminer got hold of a PSP
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Tue Nov 21, 2006 4:17 am    Post subject: Reply with quote

the underminer wrote:
A friend of mine suggested that the server closes the connection af each request. Can anyone confirm this?. He also hinted that it might be possible to 'keep the connection alive' but he didn't know the details. Can anyone tell me more about this?


General description of HTTP1.1: http://www.faqs.org/rfcs/rfc2616.html
a bit of keep-alive headers: http://www.faqs.org/rfcs/rfc2068.html
Back to top
View user's profile Send private message
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Sun Nov 26, 2006 1:02 am    Post subject: Reply with quote

im now reconnecting to a socket everytime I send something, wich works fine and is actually pretty fast
_________________
Behold! The Underminer got hold of a PSP
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group