From 2a8978feec9016ff9d5927e8c50d0a76d319e7a3 Mon Sep 17 00:00:00 2001 From: "Pat McManus @Mozilla" Date: Mon, 7 Mar 2011 06:06:36 +0000 Subject: [PATCH] interop notes - libwebsocket -06 close ... this afternoon I was just doing a little interoperability testing around close... in my test-server I added libwebsocket_close_and_free_session(this, wsi, LWS_CLOSE_STATUS_NORMAL); in order to generate a server driven close.. I hope that was the right way to go about it. In any event, in generated an invalid websocket frame - I think you want this patch, or something like it: Signed-off-by: \"Pat McManus @Mozilla\" --- lib/parsers.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/parsers.c b/lib/parsers.c index e4f17a4..fd26cb7 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -1215,9 +1215,11 @@ int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, */ if (wsi->close_reason) { - buf[pre - 2] = wsi->close_reason >> 8; - buf[pre - 1] = wsi->close_reason; - pre += 2; + /* reason codes count as data bytes */ + buf -= 2; + buf[0] = wsi->close_reason >> 8; + buf[1] = wsi->close_reason; + len += 2; } break; } -- 2.7.4