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

Trac trac at libwebsockets.org
Fri Feb 15 10:28:52 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):

 This does not work for me.

 - Setup a timer that pings the server
 - If pong not received within 1 minute, call a callback that kills the
 websocket connection.
   * This is done by setting a flag in my "user context" which I passed to
 libwebsockets, and then ask for a writable callback.

 To me this seems a bit cumbersome. Why can't there be some internal flag
 that tells libwebsocket to kill/free the session when it is suitable
 internally. I understand the old close call would release the session
 right away, which could lead to problems.

 Anyway, the above described scenario does not work. Since the network
 connection is gone, the socket doesn't seem to ever become writable, so
 the callback is never called, and I cannot return -1 to force a close of
 the connection.

 What happens right after I call
 '''libwebsocket_callback_on_writable(context, wsi);''' is not that I get a
 '''LWS_CALLBACK_CLIENT_WRITEABLE''' callback, but instead I get a
 '''LWS_CALLBACK_SET_MODE_POLL_FD''', which does not return the
 user_context but the socket in the user pointer.

 I know I can use a global flag to do this, but I'd prefer to have
 everything in the user context. One way would to maybe change it so that
 the '''void *user''' pointer in the callback always returns the user
 context. And if you need the socket for the POLL callbacks, instead have a
 libwebsocket_get_poll_socket(wsi) that can be called or something.

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

More information about the Libwebsockets mailing list