How to check a socket is closed or not in luasocket library?

眉间皱痕 提交于 2019-12-05 11:07:35

except by just try to read data from it (it will return nil and string 'close' when calling that).

I'm not aware of any other method. Why doesn't checking the result from reading a socket work for you?

You need to use settimeout to make the call non-blocking and check the error returned for closed (not close). You can read one byte and store it or you can try reading zero bytes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!