| View previous topic :: View next topic |
| Author |
Message |
swordman
Joined: 27 Dec 2005 Posts: 27
|
Posted: Mon Jan 02, 2006 8:42 pm Post subject: WLAN data |
|
|
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 |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
|
| Back to top |
|
 |
swordman
Joined: 27 Dec 2005 Posts: 27
|
Posted: Mon Jan 02, 2006 10:33 pm Post subject: |
|
|
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 |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Mon Jan 02, 2006 11:15 pm Post subject: |
|
|
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 |
|
 |
youresam
Joined: 06 Nov 2005 Posts: 87
|
Posted: Tue Jan 03, 2006 3:28 am Post subject: |
|
|
| 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 |
|
 |
|