added a timeout to net.recvstring
This commit is contained in:
parent
d234a9e4bf
commit
224d2160ac
@ -8,13 +8,17 @@ function net.sendstring(addr,port,msg) -- for sending lots of data
|
||||
end
|
||||
end
|
||||
function net.recvstring(addr,port)
|
||||
local fr,po,msg = ""
|
||||
local t,fr,po,msg = {},"","",""
|
||||
repeat
|
||||
_,fr,po,msg = event.pull("net_msg")
|
||||
t,fr,po,msg = event.pull("net_msg",10)
|
||||
if not t then
|
||||
return
|
||||
end
|
||||
until fr == addr and po == port
|
||||
local ml,s = tonumber(msg), ""
|
||||
for i = 1, ml do
|
||||
_,fr,po,msg = event.pull("net_msg")
|
||||
t,fr,po,msg = event.pull("net_msg",10)
|
||||
if t == nil then break end
|
||||
if fr == addr and po == port then
|
||||
s=s..tostring(msg)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user