xHasKx / luamqtt

luamqtt - Pure-lua MQTT v3.1.1 and v5.0 client
https://xhaskx.github.io/luamqtt/
MIT License
154 stars 41 forks source link

socket shutdown vs close #35

Closed Tieske closed 1 year ago

Tieske commented 2 years ago

the luasocket connector uses shutdown; https://github.com/xHasKx/luamqtt/blob/eacac48e31aa1a58974ef05d76687d8554a33207/mqtt/luasocket.lua#L22

the luasec based luasocket_ssl connector however uses close; https://github.com/xHasKx/luamqtt/blob/eacac48e31aa1a58974ef05d76687d8554a33207/mqtt/luasocket_ssl.lua#L45

is there a reason behind these asymmetrical calls?

xHasKx commented 2 years ago

When conn.sock is a luasec connection instance - it does not have the :shutdown() method AFAIK

xHasKx commented 2 years ago

https://github.com/brunoos/luasec/wiki/LuaSec-1.0.x#conn_close

Tieske commented 2 years ago

ah, but the method is available. Sockets are just transparent wrappers around luasocket sockets, so it should have it.

Just isn't documented.

Tieske commented 2 years ago

oops... you're right. looked at the close method, but indeed the shutdown is missing. My bad.

Tieske commented 2 years ago

see https://github.com/brunoos/luasec/issues/181

xHasKx commented 2 years ago

Please note that "close" and "shutdown" can do similar things for plain socket, and completely different actions for SSL sockets. AFAIK, "shutdown" means "do SYN/FIN packets handshake to indicate connection closing", and "close" is just hung up socket on client side. But it's possible that for SSL socket the "close" method is doing the SSL+network handshake, leading to collision with "shutdown"

Tieske commented 2 years ago

for now I just updated all to 'close', not perfect but will do I guess.