[Libwebsockets] Getting CLIENT_WRITEABLE before CLIENT_ESTABLISHED

Andy Green andy at warmcat.com
Wed Jul 16 23:16:07 CEST 2014



On 17 July 2014 01:38:24 GMT+08:00, lws14 at mordent.com wrote:
>Hi,
>
>In my app, I'm using CLIENT_ESTABLISHED to set user data for keeping 
>state (I set it to a pointer to an instance of a "Client" object). 
>However, somehow, I'm seeing other callback reasons, like 
>CLIENT_WRITEABLE, before CLIENT_ESTABLISHED happens and so my user data
>
>is empty (because ESTABLISHED hasn't happened yet).  Is this supposed
>to 
>happen this way?   I thought that CLIENT_ESTABLISHED would be the very 
>first ever callback reason we see.

No ESTABLISHED refers to the actual websocket protocol becoming established, so it only happens after various kinds of http traffic have occurred on the wsi / socket.

You want a different callback to manage the lifecycle, like LWS_CALLBACK_WSI_CREATE

http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/tree/lib/libwebsockets.h#n710

-Andy

>Thanks,
>-m
>
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.



More information about the Libwebsockets mailing list