[Libwebsockets] [libwebsockets] #15: Removal of public close...

Trac trac at libwebsockets.org
Fri Feb 15 14:26:14 CET 2013

#15: Removal of public close...
  Reporter:  Joakim                 |      Owner:  agreen
      Type:  defect                 |     Status:  new
  Priority:  major                  |  Milestone:
 Component:  libwebsockets library  |    Version:
Resolution:                         |   Keywords:

Comment (by Joakim):

 It would be called from within the callback, yes. For the poll callbacks,
 '''wsi->sock''' is passed on to the callback instead of

 What I don't get is, why is there no way to kill the connection, whenever
 I want, for whatever reason? For instance the pong situation, if there is
 no pong reply, I want the connection dead no matter what. I don't care if
 the socket is writeable or not, tear it all down, free the session and
 tell me when it's done.

 Right now to achieve the same thing I need to do the following (in the

 if (wsi && libwebsockets_get_protocol(wsi))
   user_context = libwebsocket_ensure_user_space(wsi);

 My new API call wouldn't be much difference, except the name and what it
 does is a lot more straight forward. It doesn't allocate anything, or have
 any side effects, it simply gives me the wsi->user_space pointer.

 if (wsi)
   user_context = libwebsocket_session_context_user(wsi);

 (The protocol check in the first example could be fixed by checking that
 wsi->protocol isn't NULL in libwebsocket_ensure_user_space() ofcourse)

 Right now, when the pong reply times out, I request a write. I get poll
 callbacks, but nothing else. I don't want to depend on anything to
 shutdown, I just want it shut down! Having to request a callback on
 writable, when the socket never becomes writable anyway is not working.

 I want something like:

 This should then set some internal flag, that in turn calls
 '''libwebsocket_close_and_free_session''' when it is safe.

 Or maybe there is some other way to do this?

Ticket URL: <http://libwebsockets.org/trac/ticket/15#comment:9>
libwebsockets <http://libwebsockets.org>
libwebsockets C library

More information about the Libwebsockets mailing list