[Libwebsockets] return values for callback_function

Andy Green andy at warmcat.com
Fri Nov 20 04:19:38 CET 2015

On 20 November 2015 10:58:11 GMT+08:00, shyam goyal <shyam_iisc at yahoo.com> wrote:
>blockquote, div.yahoo_quoted { margin-left: 0 !important;
>border-left:1px #715FFA solid !important;  padding-left:1ex !important;
>background-color:white !important; } Hi Andy,
>I am having a subsequent question related to this. I observe that
>sometime even after returning -1 websocket connection is not closed.

Can you let me know which callback it was?


> My service loop is running in a separate thread. I notice this problem
>especially on Windows. Regards: Shyam Sunder Goyal 
>On Thursday, 19 November 2015 9:48 PM, Andy Green <andy at warmcat.com>
>On 19 November 2015 21:55:01 GMT+08:00, "Charles Prévot"
><prevot at cervval.com> wrote:
>>I have a quick question regarding the return values of callback. I get
>>return 0 will continue and return -1 will close the connection, but in
>>test-server.c you also use return 1 (when building http headers). I
>>to find any reference on that, is there a difference with returning -1
>For all the 'normal' callbacks the choice is just 0 = ok and nonzero =
>die.  Originally <0 was die which is why -1 was popular.
>>Also, the family of http_header functions are not documented either so
>>not sure of the meaning of a non-zero return from their side...
>These were introduced to hide whether the underlying connection is
>using http2 or not.  Http2 deals with headers in a radically different,
>binary-coded way, with multiple different options for header encoding
>including huffman tables, and the codebook is dynamically updated
>during the kept-alive connection lifetime.  In particular you can't
>just slide from headers to content in one packet with http2 as you
>could with http1.x.
>Anyway for both http1.x and http2 connections, they will return nonzero
>in the case your requested header couldn't fit in the buffer you gave
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

More information about the Libwebsockets mailing list