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 

WLAN data

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



Joined: 27 Dec 2005
Posts: 27

PostPosted: Mon Jan 02, 2006 8:42 pm    Post subject: WLAN data Reply with quote

Hi all!
I'm tring to request a page from a server. I've slready studied the WLAN example, but i noticed that the recive operation is inside a loop.
When I tried to obtain tha data of a page, I understand that a single recv is not enougth for all data.
How can I make a loop that ends whal all data are obtained?
Thanks
Back to top
View user's profile Send private message
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Mon Jan 02, 2006 9:02 pm    Post subject: Reply with quote

Socket:isConnected()

http://wiki.ps2dev.org/psp:lua_player:functions

Search wlan/socket/wifi
Back to top
View user's profile Send private message
swordman



Joined: 27 Dec 2005
Posts: 27

PostPosted: Mon Jan 02, 2006 10:33 pm    Post subject: Reply with quote

Do you mean something like this?

while (Socket:IsConnected(MySock))
MySock.recv(data)
end

Because I aòready know about this function but I think that this function return true when I can use the recv o send command.
Instead I need to know if there are some data pending on the connection, data thai i don't have already recived.
Back to top
View user's profile Send private message
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Mon Jan 02, 2006 11:15 pm    Post subject: Reply with quote

Well obviously the simplelest way is to do socket:isconnected() to get data.. and to setup a end loop code.

while (variable) do
if (not socket:isconnected()) then
variable = nil
.. or a timer to force it to do a timeout code.
end

do other stuff here

end

Please note with the HTML it is designed to close the connection right after it sends its data. So if the socket isnt connected (You have the rest of the loop to get the data)
Back to top
View user's profile Send private message
youresam



Joined: 06 Nov 2005
Posts: 87

PostPosted: Tue Jan 03, 2006 3:28 am    Post subject: Reply with quote

Code:
recieve = 0
total = ""
while recieve ~= 2 do
   buffer = socket:recv()
   if string.len(buffer) > 0  then
   recieve = 1
   total = total..buffer
   else
   if recieve == 1 then recieve =2 end
   end
end


When recieve =:
0, nothing has been recieved
1, is recieving
2, has recieved, but is no longer recieving, so break


This is how Ive done it...
Back to top
View user's profile Send private message AIM Address
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