lunarmodules / luasocket

Network support for the Lua language
http://lunarmodules.github.io/luasocket/
MIT License
1.85k stars 629 forks source link

tcp remote side client can't detect closed. (50% probably happened). #411

Closed jakitliang closed 11 months ago

jakitliang commented 1 year ago

Onece you had accept a socket:

Step1. Server side

local client = server.accpet()

Step2. Client side

client.close()

Step3. Server side

local data, err, data1 = client.receive()

if err == 'closed' then  -- 50% probably won't triggered close
  client.close()
  print('remote is closed')
end

Because the err == 'closed' is 50% to get triggered.

So not every time the remote close can let luasocket gave a check err == closed.

So Please tell me other way how to check a socket is already closed?

alerque commented 1 year ago

Any chance you could expand this into a full MWE so we can add it to the test suite and also aid in tracking this down?

alerque commented 11 months ago

I think it is possible #81 fixed this recently. We still need an MWE if you can contribute such a thing, but once we have a test case it will be worth checking against before and after that PR merge.

alerque commented 11 months ago

It seems to me this is either a duplicate of #225 or #410 (possibly even both if those two things turn out to be duplicate. Lets continue on those respective issues unless there is solid evidence for this being a unique issue.