xHasKx/luamqtt

socket shutdown vs close

Tieske opened this issue · 7 comments

the luasocket connector uses shutdown;

conn.sock:shutdown()

the luasec based luasocket_ssl connector however uses close;

conn.sock:close()

is there a reason behind these asymmetrical calls?

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

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

Just isn't documented.

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

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"

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