lua - socket send throws timeout error -


i have proxy client between 2 servers. main server s1 on internet. proxy client , second server s2 sit in same intranet. have following code (parts left out simplicity) responsible forwarding data coming s2 'as is' s1:

fsctimeout = 0.01  function send_data(sock, data, i, l)     local p,err,q = sock:send(data, i, l)     if(err == "timeout" , q ~= l)         fsctimeout = fsctimeout * 2         sock:settimeout(fsctimeout)         send_data(sock, data, q + 1, l)         fsctimeout = fsctimeout / 2         sock:settimeout(fsctimeout)     end end  while not e  rect, _, st = socket.select({csc, fsc}, nil, .01) --csc s1, fsc s2 sockets.      if(rect[fsc] ~= nil , csc ~= nil)         local data, err, part = fsc:receive(8192)         if(data ~= nil)             send_data(csc, data, 1, data:len())             totalbytesfromfp = totalbytesfromfp + data:len()         end         if(part ~= nil)             send_data(csc, part, 1, part:len())             totalbytesfromfp = totalbytesfromfp + part:len()         end     end  end 

i wrote send_data function if send timeouts, double socket timeout , try again. programs gets stuck inside send_data function without being successful in sending data. can here? (i testing trying send 1mb file, small amounts of data problem doesn't seem happenning.)

you change timeout first time after "timeout" error, never happens because default send blocking (so never times out).

just add csc:settimeout(fsctimeout) before loop.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -