[solved] lua socket - udp protocol

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Joe Black
Prole
Posts: 39
Joined: Wed Jan 21, 2015 1:57 pm

[solved] lua socket - udp protocol

Post by Joe Black »

I am programming a server receiving message from many clients

I was wondering how the udp message received are stored.
In the tutorial : networking with udp, the server loop is

Code: Select all

data = udp:receivefrom()
if data then
   ...
end
socket.sleep(0.01)
while timeout is set to 0

so message are handled everytime or every 0.01 s

In my code I want to pull all messages every 0.1 second or less
and at this rate many message can have been received between 2 pull
but messages aren't stored in a stack, isn't it ?
If there is no stack, the best implementation seem to be a thread that store them in a stack ?
if there is a stack can I do

Code: Select all

data,_,_=udp:receivefrom()
while data do
   data=udp:receivefrom()
end
?

thanks for your help
Last edited by Joe Black on Fri Jul 03, 2015 9:23 pm, edited 1 time in total.
Joe Black
Prole
Posts: 39
Joined: Wed Jan 21, 2015 1:57 pm

Re: lua socket - udp protocol

Post by Joe Black »

Ok sorry guys, with little more research I finally got my answer

the client code of the tutorial say explicitly what I wanted to know :

Code: Select all

-- there could well be more than one message waiting for us, so we'll
-- loop unbtil we run out
repeat
   data, msg= udp:receive()
until not data
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 216 guests