WLAN data

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
swordman
Posts: 27
Joined: Tue Dec 27, 2005 9:04 pm

WLAN data

Post by swordman »

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
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

Socket:isConnected()

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

Search wlan/socket/wifi
swordman
Posts: 27
Joined: Tue Dec 27, 2005 9:04 pm

Post by swordman »

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.
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

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)
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

Code: Select all

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...
Post Reply