[Libwebsockets] WSI creation
andy at warmcat.com
Tue Jan 24 09:00:51 CET 2017
On January 24, 2017 3:49:28 PM GMT+08:00, techi eth <techieth at gmail.com> wrote:
>Thanks for answer.
>What i understand from test client code for every retry we are making
>parent wsi to NULL.Is their any use of doing the same to NULL in error
>close reason provided we have assigned the same to NULL while
Yeah... because the wsi actually connects asynchronously.
The wsi is allocated in the early part of the connect... you can get ahold of it in your variable by using info.pwsi.
However some time after that, the connect or the negotiation may fail. So you want to set your record of the wsi to NULL to know that it needs to be reconnected.
The wsi may connect and do the job, and then later close. Again you need to trap the close callback and either mark it for reconnect or to understand the whole thing is complete.
>On Tue, Jan 24, 2017 at 11:05 AM, Andy Green <andy at warmcat.com> wrote:
>> On 01/24/2017 01:31 PM, techi eth wrote:
>>> I am observing scenario which I was not able to understand with WSI
>>> I have got connected with my test server & got WSI. Now if I remove
>>> network then I am getting connection error followed by WSI destroy
>>> this is due to PING/PONG with server).On Receiving WSI destroy I am
>>> again for connection with same context by
>>> Every retry I am getting error & on same I am trying again for
>>> I have observed I am getting sometime same WSI sometime different
>>> Could you please give me more on handling of WSI by libwebsocket so
>>> easy for me in handling.
>> The wsi pointer is just a chunk of memory allocated by malloc(). If
>> allocate, then free something, the same chunk of memory is free to be
>> allocated again. So there is nothing strange or wrong about what you
>> The fact you care though, suggests you're trying to tell that the wsi
>> changed... you should instead do what the test client does, set your
>> copy of the wsi to NULL when it fails to connect, or closes.
>>> Libwebsockets mailing list
>>> Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets