Hi Thierry,

There is still 'something' remaining where 'socket:settimout' is not honored. See attached script and output below (slightly modified version from before.) ran against the same ' ./tcploop 81 L W N20 A R S:"response1\r\n" R P6000 S:"response2\r\n" R [ F K ] ' with 6 second delay as before)

I've tested this with the previous 2 patches (for the socket-deadlock and socket-scheduling) applied against the current master branch.

Should it wait for the response2 when timeout is set to 1.? Or should that have produced some sort of error / nil response.?.

As can be seen from below output the second socket:receive() takes the complete 6 seconds that tcploop takes to produce its second response. Can you take a look? Thanks in advance :).

Regards,

PiBa-NL (Pieter)

---------------
response1response2

Timing:
[19:42:14.8185]: wait 1 sec
[19:42:15.8632]: create socket
[19:42:15.8632]: set timeout 1 sec
[19:42:15.8632]: connect
[19:42:15.8634]: send
[19:42:15.8634]: receive
[19:42:15.8635]: send
[19:42:15.8635]: receive
[19:42:21.9005]: close
[19:42:21.9005]: done
---------------

timers = {}
function addlogstamp(text)
  table.insert(timers, {core.now(), text})
end
function timestamp_to_string(t)
  local res = os.date("%T",t.sec).."."..string.format("%04d", t.usec//100)
  return res
end

  addlogstamp("wait 1 sec")
  core.Info("Wait for it..")
  core.sleep(1)

  local result = ""
  addlogstamp("create socket")
    con = core.tcp()
  addlogstamp("set timeout 1 sec")
    con:settimeout(1)
  addlogstamp("connect")
    con:connect("127.0.0.1",81)
  addlogstamp("send")
    con:send("Test1\r\n")
  addlogstamp("receive")
    r = con:receive("*l")
    result = result .. tostring(r)
  addlogstamp("send")
    con:send("Test\r\n")
  addlogstamp("receive")
    r2 = con:receive("*l")
  addlogstamp("close")
    result = result .. tostring(r2)
    con:close()
  addlogstamp("done")

result = result .. "\n\nTiming:\n"
for x,t in pairs(timers) do
  result = result ..  "["..timestamp_to_string(t[1]) .. "]: "..t[2] .. "\n"
end
return result

Reply via email to