lipp / lua-websockets

Websockets for Lua.
http://lipp.github.com/lua-websockets/
MIT License
396 stars 113 forks source link

Is closing socket really needed? #69

Closed SyRenity closed 9 years ago

SyRenity commented 9 years ago

In the example I see that the socket is closed: https://github.com/lipp/lua-websockets/blob/master/examples/echo-server-copas.lua

    if message then
      ws:send(message)
    else
      ws:close()
      return
    end

I tried both with and without, and it seems there is no need to re-open the socket from the client site.

What is the actual use of this, and is it really needed?

lipp commented 9 years ago

you can skip close as the server closes on error (https://github.com/lipp/lua-websockets/blob/master/src/websocket/sync.lua#L84).

i recommend to call close anyhow to be more verbose on resource management.

SyRenity commented 9 years ago

@lipp Just to confirm, it will go to the error branch if the message was not received during step timeout?

Or there are other conditions that it can end up on the error code branch?